summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CodeGenAction.cpp4
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp8
-rw-r--r--clang/lib/CodeGen/CodeGenModule.h7
-rw-r--r--clang/lib/CodeGen/ModuleBuilder.cpp4
-rw-r--r--clang/lib/Frontend/MultiplexConsumer.cpp4
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiateDecl.cpp7
6 files changed, 18 insertions, 16 deletions
diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp
index b669d994ad8..6a184e0ef92 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -73,8 +73,8 @@ namespace clang {
llvm::Module *takeModule() { return TheModule.take(); }
llvm::Module *takeLinkModule() { return LinkModule.take(); }
- virtual void MarkVarRequired(VarDecl *VD) {
- Gen->MarkVarRequired(VD);
+ virtual void HandleCXXStaticMemberVarInstantiation(VarDecl *VD) {
+ Gen->HandleCXXStaticMemberVarInstantiation(VD);
}
virtual void Initialize(ASTContext &Ctx) {
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index b2bfab055b6..0399ec479e7 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1722,8 +1722,12 @@ static void ReplaceUsesOfNonProtoTypeWithRealFunction(llvm::GlobalValue *Old,
}
}
-void CodeGenModule::MarkVarRequired(VarDecl *VD) {
- GetAddrOfGlobalVar(VD);
+void CodeGenModule::HandleCXXStaticMemberVarInstantiation(VarDecl *VD) {
+ TemplateSpecializationKind TSK = VD->getTemplateSpecializationKind();
+ // If we have a definition, this might be a deferred decl. If the
+ // instantiation is explicit, make sure we emit it at the end.
+ if (VD->getDefinition() && TSK == TSK_ExplicitInstantiationDefinition)
+ GetAddrOfGlobalVar(VD);
}
void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD) {
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index 93eee444310..d6983ce7822 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -658,10 +658,9 @@ public:
/// EmitTopLevelDecl - Emit code for a single top level declaration.
void EmitTopLevelDecl(Decl *D);
- /// MarkVarRequired - Tell the consumer that this variable must be output.
- /// This is needed when the definition is initially one that can be deferred,
- /// but we then see an explicit template instantiation definition.
- void MarkVarRequired(VarDecl *VD);
+ /// HandleCXXStaticMemberVarInstantiation - Tell the consumer that this
+ // variable has been instantiated.
+ void HandleCXXStaticMemberVarInstantiation(VarDecl *VD);
/// AddUsedGlobal - Add a global which should be forced to be
/// present in the object file; these are emitted to the llvm.used
diff --git a/clang/lib/CodeGen/ModuleBuilder.cpp b/clang/lib/CodeGen/ModuleBuilder.cpp
index f81f6236d62..bcd3c0c5608 100644
--- a/clang/lib/CodeGen/ModuleBuilder.cpp
+++ b/clang/lib/CodeGen/ModuleBuilder.cpp
@@ -59,8 +59,8 @@ namespace {
*M, *TD, Diags));
}
- virtual void MarkVarRequired(VarDecl *VD) {
- Builder->MarkVarRequired(VD);
+ virtual void HandleCXXStaticMemberVarInstantiation(VarDecl *VD) {
+ Builder->HandleCXXStaticMemberVarInstantiation(VD);
}
virtual bool HandleTopLevelDecl(DeclGroupRef DG) {
diff --git a/clang/lib/Frontend/MultiplexConsumer.cpp b/clang/lib/Frontend/MultiplexConsumer.cpp
index a1d1156529f..992eeb0f2b9 100644
--- a/clang/lib/Frontend/MultiplexConsumer.cpp
+++ b/clang/lib/Frontend/MultiplexConsumer.cpp
@@ -209,9 +209,9 @@ bool MultiplexConsumer::HandleTopLevelDecl(DeclGroupRef D) {
return Continue;
}
-void MultiplexConsumer::MarkVarRequired(VarDecl *VD) {
+void MultiplexConsumer::HandleCXXStaticMemberVarInstantiation(VarDecl *VD) {
for (size_t i = 0, e = Consumers.size(); i != e; ++i)
- Consumers[i]->MarkVarRequired(VD);
+ Consumers[i]->HandleCXXStaticMemberVarInstantiation(VD);
}
void MultiplexConsumer::HandleInterestingDecl(DeclGroupRef D) {
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 4633db737ac..7d2ec16cbac 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2609,12 +2609,11 @@ void Sema::InstantiateStaticDataMemberDefinition(
if (TSK == TSK_ExplicitInstantiationDeclaration)
return;
+ Consumer.HandleCXXStaticMemberVarInstantiation(Var);
+
// If we already have a definition, we're done.
- if (Var->getDefinition()) {
- if (TSK == TSK_ExplicitInstantiationDefinition)
- Consumer.MarkVarRequired(Var);
+ if (Var->getDefinition())
return;
- }
InstantiatingTemplate Inst(*this, PointOfInstantiation, Var);
if (Inst)
OpenPOWER on IntegriCloud