summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExprCXX.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-12-23 18:19:08 +0000
committerDouglas Gregor <dgregor@apple.com>2009-12-23 18:19:08 +0000
commit25ab25f39de93e0d15a22d1811cf1804f7e20aaa (patch)
treef729fafe8c3af788b64059a4bba3c2018c09121d /clang/lib/AST/ExprCXX.cpp
parent55e74a1a6af31305ebafe7c14805b54fd5fa7822 (diff)
downloadbcm5719-llvm-25ab25f39de93e0d15a22d1811cf1804f7e20aaa.tar.gz
bcm5719-llvm-25ab25f39de93e0d15a22d1811cf1804f7e20aaa.zip
When using a default function argument for a function template (or
member function thereof), perform the template instantiation each time the default argument is needed. This ensures that (1) We get different CXXTemporary objects for each instantiation, and (2) Any other instantiations or definitions triggered by the instantiation of the default argument expression are guaranteed to happen; previously, they might have been suppressed, e.g., because they happened in an unevaluated context. This fixes the majority of PR5810. However, it does not address the problem where we may have multiple uses of the same CXXTemporary within an expression when the temporary came from a non-instantiated default argument expression. llvm-svn: 92015
Diffstat (limited to 'clang/lib/AST/ExprCXX.cpp')
-rw-r--r--clang/lib/AST/ExprCXX.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index 5444a7748cb..e4538fdfedf 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -352,6 +352,19 @@ const char *CXXNamedCastExpr::getCastName() const {
}
}
+CXXDefaultArgExpr *
+CXXDefaultArgExpr::Create(ASTContext &C, ParmVarDecl *Param, Expr *SubExpr) {
+ void *Mem = C.Allocate(sizeof(CXXDefaultArgExpr) + sizeof(Stmt *));
+ return new (Mem) CXXDefaultArgExpr(CXXDefaultArgExprClass, Param, SubExpr);
+}
+
+void CXXDefaultArgExpr::DoDestroy(ASTContext &C) {
+ if (Param.getInt())
+ getExpr()->Destroy(C);
+ this->~CXXDefaultArgExpr();
+ C.Deallocate(this);
+}
+
CXXTemporary *CXXTemporary::Create(ASTContext &C,
const CXXDestructorDecl *Destructor) {
return new (C) CXXTemporary(Destructor);
OpenPOWER on IntegriCloud