]> granicus.if.org Git - clang/commitdiff
give always_inline functions internal linkage. If they cannot be
authorChris Lattner <sabre@nondot.org>
Tue, 14 Apr 2009 06:32:05 +0000 (06:32 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 14 Apr 2009 06:32:05 +0000 (06:32 +0000)
inlined for some reason, then we don't want a strong or even weak
definition.

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

lib/CodeGen/CodeGenModule.cpp

index adf5ac2e414437b0594c8247a402bb78cd39698c..5ef57ffdcc205ddd596ec9cd42d6af783676fa45 100644 (file)
@@ -325,7 +325,9 @@ void CodeGenModule::SetFunctionAttributes(const Decl *D,
 static CodeGenModule::GVALinkage 
 GetLinkageForFunctionOrMethodDecl(const Decl *D) {
   if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
-    if (FD->getStorageClass() == FunctionDecl::Static)
+    // "static" and attr(always_inline) functions get internal linkage.
+    if (FD->getStorageClass() == FunctionDecl::Static ||
+        FD->hasAttr<AlwaysInlineAttr>())
       return CodeGenModule::GVA_Internal;
     if (FD->isInline()) {
       if (FD->getStorageClass() == FunctionDecl::Extern)