[cfe-commits] r145203 - in /cfe/trunk: lib/AST/ExprCXX.cpp lib/Sema/SemaExprCXX.cpp test/CodeGenCXX/temporaries.cpp
Peter Collingbourne
peter at pcc.me.uk
Sun Nov 27 14:09:28 PST 2011
Author: pcc
Date: Sun Nov 27 16:09:28 2011
New Revision: 145203
URL: http://llvm.org/viewvc/llvm-project?rev=145203&view=rev
Log:
In Sema::MaybeBindToTemporary, create a CXXBindTemporaryExpr for an
array of objects with non-trivial destructors. PR11365.
Modified:
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/CodeGenCXX/temporaries.cpp
Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=145203&r1=145202&r2=145203&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Sun Nov 27 16:09:28 2011
@@ -618,8 +618,9 @@
CXXBindTemporaryExpr *CXXBindTemporaryExpr::Create(ASTContext &C,
CXXTemporary *Temp,
Expr* SubExpr) {
- assert(SubExpr->getType()->isRecordType() &&
- "Expression bound to a temporary must have record type!");
+ assert((SubExpr->getType()->isRecordType() ||
+ SubExpr->getType()->isArrayType()) &&
+ "Expression bound to a temporary must have record or array type!");
return new (C) CXXBindTemporaryExpr(Temp, SubExpr);
}
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=145203&r1=145202&r2=145203&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Sun Nov 27 16:09:28 2011
@@ -4116,7 +4116,8 @@
if (!getLangOptions().CPlusPlus)
return Owned(E);
- const RecordType *RT = E->getType()->getAs<RecordType>();
+ QualType ET = Context.getBaseElementType(E->getType());
+ const RecordType *RT = ET->getAs<RecordType>();
if (!RT)
return Owned(E);
Modified: cfe/trunk/test/CodeGenCXX/temporaries.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/temporaries.cpp?rev=145203&r1=145202&r2=145203&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/temporaries.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/temporaries.cpp Sun Nov 27 16:09:28 2011
@@ -519,3 +519,21 @@
b ? A(2) : A(3);
}
}
+
+namespace PR11365 {
+ struct A { A(); ~A(); };
+
+ // CHECK: define void @_ZN7PR113653fooEv(
+ void foo() {
+ // CHECK: [[BEGIN:%.*]] = getelementptr inbounds [3 x [[A:%.*]]]* {{.*}}, i32 0, i32 0
+ // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds [[A]]* [[BEGIN]], i64 3
+ // CHECK-NEXT: br label
+
+ // CHECK: [[PHI:%.*]] = phi
+ // CHECK-NEXT: [[ELEM:%.*]] = getelementptr inbounds [[A]]* [[PHI]], i64 -1
+ // CHECK-NEXT: call void @_ZN7PR113651AD1Ev([[A]]* [[ELEM]])
+ // CHECK-NEXT: icmp eq [[A]]* [[ELEM]], [[BEGIN]]
+ // CHECK-NEXT: br i1
+ (void) (A [3]) {};
+ }
+}
More information about the cfe-commits
mailing list