[cfe-commits] r152320 - in /cfe/trunk: include/clang/AST/ASTConsumer.h include/clang/Frontend/MultiplexConsumer.h lib/CodeGen/CodeGenAction.cpp lib/CodeGen/CodeGenModule.cpp lib/CodeGen/CodeGenModule.h lib/CodeGen/ModuleBuilder.cpp lib/Frontend/MultiplexConsumer.cpp lib/Sema/SemaTemplateInstantiateDecl.cpp

Rafael Espindola rafael.espindola at gmail.com
Thu Mar 8 07:51:03 PST 2012


Author: rafael
Date: Thu Mar  8 09:51:03 2012
New Revision: 152320

URL: http://llvm.org/viewvc/llvm-project?rev=152320&view=rev
Log:
Replace MarkVarRequired with a more generic
HandleCXXStaticMemberVarInstantiation. Suggested by Argyrios.

Modified:
    cfe/trunk/include/clang/AST/ASTConsumer.h
    cfe/trunk/include/clang/Frontend/MultiplexConsumer.h
    cfe/trunk/lib/CodeGen/CodeGenAction.cpp
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp
    cfe/trunk/lib/CodeGen/CodeGenModule.h
    cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
    cfe/trunk/lib/Frontend/MultiplexConsumer.cpp
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/include/clang/AST/ASTConsumer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTConsumer.h?rev=152320&r1=152319&r2=152320&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTConsumer.h (original)
+++ cfe/trunk/include/clang/AST/ASTConsumer.h Thu Mar  8 09:51:03 2012
@@ -90,10 +90,9 @@
   /// modified by the introduction of an implicit zero initializer.
   virtual void CompleteTentativeDefinition(VarDecl *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.
-  virtual void MarkVarRequired(VarDecl *D) {}
+  /// HandleCXXStaticMemberVarInstantiation - Tell the consumer that this
+  // variable has been instantiated.
+  virtual void HandleCXXStaticMemberVarInstantiation(VarDecl *D) {}
 
   /// \brief Callback involved at the end of a translation unit to
   /// notify the consumer that a vtable for the given C++ class is

Modified: cfe/trunk/include/clang/Frontend/MultiplexConsumer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/MultiplexConsumer.h?rev=152320&r1=152319&r2=152320&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/MultiplexConsumer.h (original)
+++ cfe/trunk/include/clang/Frontend/MultiplexConsumer.h Thu Mar  8 09:51:03 2012
@@ -35,7 +35,7 @@
 
   // ASTConsumer
   virtual void Initialize(ASTContext &Context);
-  virtual void MarkVarRequired(VarDecl *VD);
+  virtual void HandleCXXStaticMemberVarInstantiation(VarDecl *VD);
   virtual bool HandleTopLevelDecl(DeclGroupRef D);
   virtual void HandleInterestingDecl(DeclGroupRef D);
   virtual void HandleTranslationUnit(ASTContext &Ctx);

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=152320&r1=152319&r2=152320&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Thu Mar  8 09:51:03 2012
@@ -73,8 +73,8 @@
     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) {

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=152320&r1=152319&r2=152320&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Mar  8 09:51:03 2012
@@ -1722,8 +1722,12 @@
   }
 }
 
-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) {

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=152320&r1=152319&r2=152320&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Thu Mar  8 09:51:03 2012
@@ -658,10 +658,9 @@
   /// 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

Modified: cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ModuleBuilder.cpp?rev=152320&r1=152319&r2=152320&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ModuleBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/ModuleBuilder.cpp Thu Mar  8 09:51:03 2012
@@ -59,8 +59,8 @@
                                                *M, *TD, Diags));
     }
 
-    virtual void MarkVarRequired(VarDecl *VD) {
-      Builder->MarkVarRequired(VD);
+    virtual void HandleCXXStaticMemberVarInstantiation(VarDecl *VD) {
+      Builder->HandleCXXStaticMemberVarInstantiation(VD);
     }
 
     virtual bool HandleTopLevelDecl(DeclGroupRef DG) {

Modified: cfe/trunk/lib/Frontend/MultiplexConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/MultiplexConsumer.cpp?rev=152320&r1=152319&r2=152320&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/MultiplexConsumer.cpp (original)
+++ cfe/trunk/lib/Frontend/MultiplexConsumer.cpp Thu Mar  8 09:51:03 2012
@@ -209,9 +209,9 @@
   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) {

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=152320&r1=152319&r2=152320&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Thu Mar  8 09:51:03 2012
@@ -2609,12 +2609,11 @@
   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)





More information about the cfe-commits mailing list