summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGDecl.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-02-07 23:51:38 +0000
committerAnders Carlsson <andersca@mac.com>2009-02-07 23:51:38 +0000
commitcadb9a6a34c0b16619516081eb0691c9cbc74f78 (patch)
tree533025f567a73b70dcf9aad020e8aea6e3ab1cdf /clang/lib/CodeGen/CGDecl.cpp
parentbe0f76a712ddfdb6c0e4e5240174c21178280fa3 (diff)
downloadbcm5719-llvm-cadb9a6a34c0b16619516081eb0691c9cbc74f78.tar.gz
bcm5719-llvm-cadb9a6a34c0b16619516081eb0691c9cbc74f78.zip
Emit a cleanup block for the cleanup attribute
llvm-svn: 64052
Diffstat (limited to 'clang/lib/CodeGen/CGDecl.cpp')
-rw-r--r--clang/lib/CodeGen/CGDecl.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 3162c2f4805..eba4d319efc 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -226,6 +226,22 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
EmitAggExpr(Init, DeclPtr, D.getType().isVolatileQualified());
}
}
+
+ // Handle the cleanup attribute
+ if (const CleanupAttr *CA = D.getAttr<CleanupAttr>()) {
+ const FunctionDecl *FD = CA->getFunctionDecl();
+
+ llvm::Constant* F = CGM.GetAddrOfFunction(FD);
+ assert(F && "Could not find function!");
+
+ CleanupScope scope(*this);
+
+ CallArgList Args;
+ Args.push_back(std::make_pair(RValue::get(DeclPtr),
+ getContext().getPointerType(D.getType())));
+
+ EmitCall(CGM.getTypes().getFunctionInfo(FD), F, Args);
+ }
}
/// Emit an alloca (or GlobalValue depending on target)
OpenPOWER on IntegriCloud