aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--lib/CodeGen/CodeGenModule.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index e98939cc8f..3a0d2b8ddc 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -256,9 +256,18 @@ GetLinkageForFunction(ASTContext &Context, const FunctionDecl *FD,
// The kind of external linkage this function will have, if it is not
// inline or static.
CodeGenModule::GVALinkage External = CodeGenModule::GVA_StrongExternal;
- if (Context.getLangOptions().CPlusPlus &&
- FD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
- External = CodeGenModule::GVA_TemplateInstantiation;
+ if (Context.getLangOptions().CPlusPlus) {
+ TemplateSpecializationKind TSK = FD->getTemplateSpecializationKind();
+
+ if (TSK == TSK_ExplicitInstantiationDefinition) {
+ // If a function has been explicitly instantiated, then it should
+ // always have strong external linkage.
+ return CodeGenModule::GVA_StrongExternal;
+ }
+
+ if (TSK == TSK_ImplicitInstantiation)
+ External = CodeGenModule::GVA_TemplateInstantiation;
+ }
if (!FD->isInlined())
return External;