From 548e60efea9a1d2c31679e11e9ff0d2f19b96694 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Thu, 10 Dec 2009 22:25:34 +0000 Subject: Make sure that explicitly instantiated functions get the right linkage. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91069 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/CodeGen/CodeGenModule.cpp') 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; -- cgit v1.2.3-18-g5258