summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-10-27 23:26:40 +0000
committerDouglas Gregor <dgregor@apple.com>2009-10-27 23:26:40 +0000
commitb7e5c847c4331866c10562e596b747e65e3647bf (patch)
tree29c2ca7dd42dc30f71a93a504819e705e4f03e24 /clang/lib/CodeGen/CodeGenModule.cpp
parent1bafa6de57c5bea8b9b0d536cbda4ac96900a9d0 (diff)
downloadbcm5719-llvm-b7e5c847c4331866c10562e596b747e65e3647bf.tar.gz
bcm5719-llvm-b7e5c847c4331866c10562e596b747e65e3647bf.zip
Implement proper linkage for explicit instantiation declarations of
inlined functions. For example, given template<typename T> class string { unsigned Len; public: unsigned size() const { return Len; } }; extern template class string<char>; we now give the instantiation of string<char>::size available_externally linkage (if it is ever instantiated!), as permitted by the C++0x standard. llvm-svn: 85340
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index a40701851e3..db609f62453 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -253,6 +253,10 @@ GetLinkageForFunction(ASTContext &Context, const FunctionDecl *FD,
if (FD->isInAnonymousNamespace())
return CodeGenModule::GVA_Internal;
+ // "static" functions get internal linkage.
+ if (FD->getStorageClass() == FunctionDecl::Static && !isa<CXXMethodDecl>(FD))
+ return CodeGenModule::GVA_Internal;
+
// The kind of external linkage this function will have, if it is not
// inline or static.
CodeGenModule::GVALinkage External = CodeGenModule::GVA_StrongExternal;
@@ -260,18 +264,6 @@ GetLinkageForFunction(ASTContext &Context, const FunctionDecl *FD,
FD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
External = CodeGenModule::GVA_TemplateInstantiation;
- if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
- // C++ member functions defined inside the class are always inline.
- if (MD->isInlined())
- return CodeGenModule::GVA_CXXInline;
-
- return External;
- }
-
- // "static" functions get internal linkage.
- if (FD->getStorageClass() == FunctionDecl::Static)
- return CodeGenModule::GVA_Internal;
-
if (!FD->isInlined())
return External;
@@ -285,8 +277,16 @@ GetLinkageForFunction(ASTContext &Context, const FunctionDecl *FD,
return CodeGenModule::GVA_C99Inline;
}
- // C++ inline semantics
- assert(Features.CPlusPlus && "Must be in C++ mode");
+ // C++0x [temp.explicit]p9:
+ // [ Note: The intent is that an inline function that is the subject of
+ // an explicit instantiation declaration will still be implicitly
+ // instantiated when used so that the body can be considered for
+ // inlining, but that no out-of-line copy of the inline function would be
+ // generated in the translation unit. -- end note ]
+ if (FD->getTemplateSpecializationKind()
+ == TSK_ExplicitInstantiationDeclaration)
+ return CodeGenModule::GVA_C99Inline;
+
return CodeGenModule::GVA_CXXInline;
}
OpenPOWER on IntegriCloud