[cfe-commits] r64052 - /cfe/trunk/lib/CodeGen/CGDecl.cpp

Anders Carlsson andersca at mac.com
Sat Feb 7 15:51:38 PST 2009


Author: andersca
Date: Sat Feb  7 17:51:38 2009
New Revision: 64052

URL: http://llvm.org/viewvc/llvm-project?rev=64052&view=rev
Log:
Emit a cleanup block for the cleanup attribute

Modified:
    cfe/trunk/lib/CodeGen/CGDecl.cpp

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=64052&r1=64051&r2=64052&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Sat Feb  7 17:51:38 2009
@@ -226,6 +226,22 @@
       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) 





More information about the cfe-commits mailing list