]> granicus.if.org Git - clang/commitdiff
take an initial stab at setting function linkage right. Handle
authorChris Lattner <sabre@nondot.org>
Tue, 27 Nov 2007 06:46:51 +0000 (06:46 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 27 Nov 2007 06:46:51 +0000 (06:46 +0000)
static and inline at least.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44355 91177308-0d34-0410-b5e6-96231b3b80d8

CodeGen/CodeGenFunction.cpp

index e0d55b59cbab87d54ef41842e0fe5c1d28673620..3602d60029b141e06bc6dada6d113e7e490954d5 100644 (file)
@@ -60,9 +60,15 @@ void CodeGenFunction::GenerateCode(const FunctionDecl *FD) {
   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);