[cfe-commits] r115700 - in /cfe/trunk: lib/Sema/TreeTransform.h test/CodeGenCXX/goto.cpp
John McCall
rjmccall at apple.com
Tue Oct 5 15:36:42 PDT 2010
Author: rjmccall
Date: Tue Oct 5 17:36:42 2010
New Revision: 115700
URL: http://llvm.org/viewvc/llvm-project?rev=115700&view=rev
Log:
When instantiating a new-expression, force a rebuild if there were default
arguments in either the placement or constructor arguments. This is
important if the default arguments refer to a declaration or create a
temporary.
Modified:
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/CodeGenCXX/goto.cpp
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=115700&r1=115699&r2=115700&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Tue Oct 5 17:36:42 2010
@@ -5278,6 +5278,11 @@
bool ArgumentChanged = false;
ASTOwningVector<Expr*> PlacementArgs(SemaRef);
for (unsigned I = 0, N = E->getNumPlacementArgs(); I != N; ++I) {
+ if (getDerived().DropCallArgument(E->getPlacementArg(I))) {
+ ArgumentChanged = true;
+ break;
+ }
+
ExprResult Arg = getDerived().TransformExpr(E->getPlacementArg(I));
if (Arg.isInvalid())
return ExprError();
@@ -5289,8 +5294,10 @@
// transform the constructor arguments (if any).
ASTOwningVector<Expr*> ConstructorArgs(SemaRef);
for (unsigned I = 0, N = E->getNumConstructorArgs(); I != N; ++I) {
- if (getDerived().DropCallArgument(E->getConstructorArg(I)))
+ if (getDerived().DropCallArgument(E->getConstructorArg(I))) {
+ ArgumentChanged = true;
break;
+ }
ExprResult Arg = getDerived().TransformExpr(E->getConstructorArg(I));
if (Arg.isInvalid())
Modified: cfe/trunk/test/CodeGenCXX/goto.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/goto.cpp?rev=115700&r1=115699&r2=115700&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/goto.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/goto.cpp Tue Oct 5 17:36:42 2010
@@ -1,29 +1,43 @@
-// RUN: %clang-cc1 %s -fexceptions -emit-llvm-only
+// RUN: %clang-cc1 %s -triple=x86_64-apple-darwin10 -fexceptions -emit-llvm -o - | FileCheck %s
// Reduced from a crash on boost::interprocess's node_allocator_test.cpp.
namespace test0 {
struct A { A(); ~A(); };
struct V { V(const A &a = A()); ~V(); };
- template<int X> int vector_test()
- {
- A process_name;
- try {
- A segment;
+ // CHECK: define linkonce_odr i32 @_ZN5test04testILi0EEEii
+ template<int X> int test(int x) {
+ // CHECK: [[RET:%.*]] = alloca i32
+ // CHECK-NEXT: [[X:%.*]] = alloca i32
+ // CHECK-NEXT: [[Y:%.*]] = alloca [[A:%.*]],
+ // CHECK-NEXT: [[Z:%.*]] = alloca [[A]]
+ // CHECK-NEXT: [[EXN:%.*]] = alloca i8*
+ // CHECK-NEXT: alloca i32
+ // CHECK-NEXT: [[V:%.*]] = alloca [[V:%.*]]*,
+ // CHECK-NEXT: [[TMP:%.*]] = alloca [[A]]
+ // CHECK-NEXT: [[CLEANUPACTIVE:%.*]] = alloca i1
+ // CHECK: store i1 true, i1* [[CLEANUPACTIVE]]
+ // CHECK: call void @_ZN5test01AC1Ev([[A]]* [[Y]])
+ // CHECK-NEXT: invoke void @_ZN5test01AC1Ev([[A]]* [[Z]])
+ // CHECK: [[NEW:%.*]] = invoke noalias i8* @_Znwm(i64 1)
+ // CHECK: [[NEWCAST:%.*]] = bitcast i8* [[NEW]] to [[V]]*
+ // CHECK-NEXT: invoke void @_ZN5test01AC1Ev([[A]]* [[TMP]])
+ // CHECK: invoke void @_ZN5test01VC1ERKNS_1AE([[V]]* [[NEWCAST]], [[A]]* [[TMP]])
+ // CHECK: store i1 false, i1* [[CLEANUPACTIVE]]
+ // CHECK-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[TMP]])
+ A y;
+ try {
+ A z;
+ V *v = new V();
- V *stdvector = new V();
+ if (x) return 1;
+ } catch (int ex) {
+ return 1;
+ }
+ return 0;
+ }
- int x = 5, y = 7;
- if(x == y) return 1;
- }
- catch(int ex){
- return 1;
- }
- return 0;
-}
-
-int main ()
-{
- return vector_test<0>();
-}
+ int test() {
+ return test<0>(5);
+ }
}
More information about the cfe-commits
mailing list