[CodeGen] Ignore OpaqueValueExprs that are unique references to their
authorAkira Hatanaka <ahatanaka@apple.com>
Tue, 20 Mar 2018 01:47:58 +0000 (01:47 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Tue, 20 Mar 2018 01:47:58 +0000 (01:47 +0000)
commit797afe3a4ed475d26786a31ede9ac6a9e790608d
tree4f2914b8f20f3294ead7d5335e2af0e2b2aed277
parentcbd498ac10427778a6133b9dc3a78c3a5e9ec6cd
[CodeGen] Ignore OpaqueValueExprs that are unique references to their
source expressions when iterating over a PseudoObjectExpr's semantic
subexpression list.

Previously the loop in emitPseudoObjectExpr would emit the IR for each
OpaqueValueExpr that was in a PseudoObjectExpr's semantic-form
expression list and use the result when the OpaqueValueExpr later
appeared in other expressions. This caused an assertion failure when
AggExprEmitter tried to copy the result of an OpaqueValueExpr and the
copied type didn't have trivial copy/move constructors or assignment
operators.

This patch adds flag IsUnique to OpaqueValueExpr which indicates it is a
unique reference to its source expression (it is not used in multiple
places). The loop in emitPseudoObjectExpr ignores OpaqueValueExprs that
are unique and CodeGen visitors simply traverse the source expressions
of such OpaqueValueExprs.

rdar://problem/34363596

Differential Revision: https://reviews.llvm.org/D39562

llvm-svn: 327939
14 files changed:
clang/include/clang/AST/Expr.h
clang/include/clang/AST/Stmt.h
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGExprAgg.cpp
clang/lib/CodeGen/CGExprComplex.cpp
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Sema/SemaPseudoObject.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/test/CodeGenCXX/ms-property.cpp
clang/test/CodeGenObjC/objc-container-subscripting-1.m
clang/test/CodeGenObjCXX/property-dot-copy-elision.mm [new file with mode: 0644]
clang/test/CodeGenObjCXX/property-objects.mm