summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGCXX.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-09-04 19:04:08 +0000
committerDouglas Gregor <dgregor@apple.com>2009-09-04 19:04:08 +0000
commitd94105a1c2e133ede54baeea911975abed93f457 (patch)
treec1f7cf2f91fcad5ff5ba3c44de0f43c2b78e1f77 /clang/lib/CodeGen/CGCXX.cpp
parent35337557af5ebe1905a3013b1843e48ce00c48d3 (diff)
downloadbcm5719-llvm-d94105a1c2e133ede54baeea911975abed93f457.tar.gz
bcm5719-llvm-d94105a1c2e133ede54baeea911975abed93f457.zip
Don't generate any code for an explicit call to a trivial destructor.
Now that parsing, semantic analysis, and (I think) code generation of pseudo-destructor expressions and explicit destructor calls works, update the example-dynarray.cpp test to destroy the objects it allocates and update the test to actually compile + link. The code seems correct, but the Clang-compiled version dies with a malloc error. Time to debug! llvm-svn: 81025
Diffstat (limited to 'clang/lib/CodeGen/CGCXX.cpp')
-rw-r--r--clang/lib/CodeGen/CGCXX.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp
index 7655f47e44f..4f0d9a0c5cd 100644
--- a/clang/lib/CodeGen/CGCXX.cpp
+++ b/clang/lib/CodeGen/CGCXX.cpp
@@ -178,6 +178,11 @@ RValue CodeGenFunction::EmitCXXMemberCall(const CXXMethodDecl *MD,
assert(MD->isInstance() &&
"Trying to emit a member call expr on a static method!");
+ // A call to a trivial destructor requires no code generation.
+ if (const CXXDestructorDecl *Destructor = dyn_cast<CXXDestructorDecl>(MD))
+ if (Destructor->isTrivial())
+ return RValue::get(0);
+
const FunctionProtoType *FPT = MD->getType()->getAsFunctionProtoType();
CallArgList Args;
@@ -218,6 +223,9 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE) {
llvm::Value *Callee;
if (MD->isVirtual() && !ME->hasQualifier())
Callee = BuildVirtualCall(MD, This, Ty);
+ else if (const CXXDestructorDecl *Destructor
+ = dyn_cast<CXXDestructorDecl>(MD))
+ Callee = CGM.GetAddrOfFunction(GlobalDecl(Destructor, Dtor_Complete), Ty);
else
Callee = CGM.GetAddrOfFunction(GlobalDecl(MD), Ty);
OpenPOWER on IntegriCloud