[cfe-commits] r108218 - in /cfe/trunk: include/clang/AST/DeclBase.h lib/AST/DeclBase.cpp lib/Sema/SemaTemplateInstantiateDecl.cpp

Fariborz Jahanian fjahanian at apple.com
Mon Jul 12 17:16:40 PDT 2010


Author: fjahanian
Date: Mon Jul 12 19:16:40 2010
New Revision: 108218

URL: http://llvm.org/viewvc/llvm-project?rev=108218&view=rev
Log:
Instantiate attributes when first building an instantiated
VarDecl.

Modified:
    cfe/trunk/include/clang/AST/DeclBase.h
    cfe/trunk/lib/AST/DeclBase.cpp
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=108218&r1=108217&r2=108218&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Mon Jul 12 19:16:40 2010
@@ -312,7 +312,6 @@
     return getAttrsImpl();    // Uncommon case, out of line hash lookup.
   }
   void swapAttrs(Decl *D);
-  void copyAttrs(Decl *D);
   void invalidateAttrs();
 
   template<typename T> const T *getAttr() const {

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=108218&r1=108217&r2=108218&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Mon Jul 12 19:16:40 2010
@@ -372,18 +372,6 @@
   RHS->HasAttrs = true;
 }
 
-void Decl::copyAttrs(Decl *SRC) {
-  if (!SRC->hasAttrs())
-    return;
-  ASTContext &Context = getASTContext();
-  for (const Attr *attr = SRC->getAttrs(); attr; attr = attr->getNext()) {
-    Attr *NewAttr = attr->clone(Context);
-    addAttr(const_cast<Attr*>(NewAttr));
-  }
-  HasAttrs = true;
-}
-
-
 void Decl::Destroy(ASTContext &C) {
   // Free attributes for this decl.
   if (HasAttrs) {

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=108218&r1=108217&r2=108218&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Mon Jul 12 19:16:40 2010
@@ -396,11 +396,11 @@
     Owner->makeDeclVisibleInContext(Var);
   } else {
     Owner->addDecl(Var);
-    
     if (Owner->isFunctionOrMethod())
       SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Var);
   }
-
+  InstantiateAttrs(D, Var);
+  
   // Link instantiations of static data members back to the template from
   // which they were instantiated.
   if (Var->isStaticDataMember())
@@ -2591,10 +2591,7 @@
       ParentDC->isFunctionOrMethod()) {
     // D is a local of some kind. Look into the map of local
     // declarations to their instantiations.
-    NamedDecl *ND = 
-      cast<NamedDecl>(CurrentInstantiationScope->getInstantiationOf(D));
-    ND->copyAttrs(D);
-    return ND;
+    return cast<NamedDecl>(CurrentInstantiationScope->getInstantiationOf(D));
   }
 
   if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(D)) {





More information about the cfe-commits mailing list