[cfe-commits] r44355 - /cfe/trunk/CodeGen/CodeGenFunction.cpp

Chris Lattner sabre at nondot.org
Mon Nov 26 22:46:52 PST 2007


Author: lattner
Date: Tue Nov 27 00:46:51 2007
New Revision: 44355

URL: http://llvm.org/viewvc/llvm-project?rev=44355&view=rev
Log:
take an initial stab at setting function linkage right.  Handle
static and inline at least.

Modified:
    cfe/trunk/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenFunction.cpp?rev=44355&r1=44354&r2=44355&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/CodeGen/CodeGenFunction.cpp Tue Nov 27 00:46:51 2007
@@ -60,9 +60,15 @@
   CurFn = cast<llvm::Function>(CGM.GetAddrOfGlobalDecl(FD));
   CurFuncDecl = FD;
   
-  // TODO: Set up linkage and many other things.
   assert(CurFn->isDeclaration() && "Function already has body?");
   
+  // TODO: Set up linkage and many other things.  Note, this is a simple 
+  // approximation of what we really want.
+  if (FD->getStorageClass() == FunctionDecl::Static)
+    CurFn->setLinkage(llvm::Function::InternalLinkage);
+  else if (FD->isInline())
+    CurFn->setLinkage(llvm::Function::WeakLinkage);
+  
   llvm::BasicBlock *EntryBB = new llvm::BasicBlock("entry", CurFn);
   
   Builder.SetInsertPoint(EntryBB);





More information about the cfe-commits mailing list