summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplate.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-04-24 22:45:46 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-04-24 22:45:46 +0000
commiteb36ddf462de5621fab3a1fb064f526d7bd5fb3d (patch)
treea08ef1c37dde709da7fdc2243f281b734e521cc6 /clang/lib/Sema/SemaTemplate.cpp
parent9a5c95ad3adb9cf6dd1957dc36b0d9bf4d73fe55 (diff)
downloadbcm5719-llvm-eb36ddf462de5621fab3a1fb064f526d7bd5fb3d.tar.gz
bcm5719-llvm-eb36ddf462de5621fab3a1fb064f526d7bd5fb3d.zip
If we see an explicit instantiation declaration or definition of a function
after we've already instantiated a definition for the function, pass it to the ASTConsumer again so that it knows the specialization kind has changed and can update the function's linkage. This only matters if we instantiate the definition of the function before we reach the end of the TU; this can happen in at least three different ways: C++11 constexpr functions, C++14 deduced return types, and functions instantiated within modules. llvm-svn: 207152
Diffstat (limited to 'clang/lib/Sema/SemaTemplate.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplate.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 64c32638051..fb35f9084f7 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -7188,6 +7188,7 @@ Sema::ActOnExplicitInstantiation(Scope *S,
// TSK_ExplicitInstantiationDefinition
if (Old_TSK == TSK_ExplicitInstantiationDeclaration &&
TSK == TSK_ExplicitInstantiationDefinition)
+ // FIXME: Need to notify the ASTMutationListener that we did this.
Def->setTemplateSpecializationKind(TSK);
InstantiateClassTemplateSpecializationMembers(TemplateNameLoc, Def, TSK);
@@ -7624,7 +7625,11 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
if (Attr)
ProcessDeclAttributeList(S, Specialization, Attr);
- if (TSK == TSK_ExplicitInstantiationDefinition)
+ if (Specialization->isDefined()) {
+ // Let the ASTConsumer know that this function has been explicitly
+ // instantiated now, and its linkage might have changed.
+ Consumer.HandleTopLevelDecl(DeclGroupRef(Specialization));
+ } else if (TSK == TSK_ExplicitInstantiationDefinition)
InstantiateFunctionDefinition(D.getIdentifierLoc(), Specialization);
// C++0x [temp.explicit]p2:
OpenPOWER on IntegriCloud