[cfe-commits] r78222 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaInit.cpp test/CodeGenCXX/default-arg-temps.cpp
Fariborz Jahanian
fjahanian at apple.com
Wed Aug 5 11:17:48 PDT 2009
Author: fjahanian
Date: Wed Aug 5 13:17:32 2009
New Revision: 78222
URL: http://llvm.org/viewvc/llvm-project?rev=78222&view=rev
Log:
Handle destruction of temporaries used in default argument
construction of constructor calls.
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/CodeGenCXX/default-arg-temps.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=78222&r1=78221&r2=78222&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Aug 5 13:17:32 2009
@@ -2396,6 +2396,7 @@
DeclInitType, Constructor,
false, Exprs, NumExprs);
MarkDeclarationReferenced(VD->getLocation(), Constructor);
+ Temp = MaybeCreateCXXExprWithTemporaries(Temp, /*DestroyTemps=*/true);
VD->setInit(Context, Temp);
}
Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=78222&r1=78221&r2=78222&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Wed Aug 5 13:17:32 2009
@@ -179,6 +179,7 @@
Init = BuildCXXConstructExpr(Context,
DeclType, Constructor, false, &Init, 1);
+ Init = MaybeCreateCXXExprWithTemporaries(Init, /*DestroyTemps=*/true);
return false;
}
Modified: cfe/trunk/test/CodeGenCXX/default-arg-temps.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/default-arg-temps.cpp?rev=78222&r1=78221&r2=78222&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/default-arg-temps.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/default-arg-temps.cpp Wed Aug 5 13:17:32 2009
@@ -7,9 +7,19 @@
void f(const T& t = T());
+class X { // ...
+public:
+ X();
+ X(const X&, const T& t = T());
+};
+
void g() {
- // RUN: grep "call void @_ZN1TC1Ev" %t | count 2 &&
- // RUN: grep "call void @_ZN1TD1Ev" %t | count 2
+ // RUN: grep "call void @_ZN1TC1Ev" %t | count 4 &&
+ // RUN: grep "call void @_ZN1TD1Ev" %t | count 4
f();
f();
+
+ X a;
+ X b(a);
+ X c = a;
}
More information about the cfe-commits
mailing list