diff options
author | Anders Carlsson <andersca@mac.com> | 2009-02-07 23:51:38 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-02-07 23:51:38 +0000 |
commit | 69c68b7454dc7f47def4ebf593a584d0f02c1ddb (patch) | |
tree | 965e9cd0e2d153c78f616d519b1c04eb6b659c84 /lib/CodeGen/CGDecl.cpp | |
parent | c71c845fe77ee1f891d60232ec320912d88557ee (diff) |
Emit a cleanup block for the cleanup attribute
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64052 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDecl.cpp')
-rw-r--r-- | lib/CodeGen/CGDecl.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index 3162c2f480..eba4d319ef 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/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) |