]> granicus.if.org Git - clang/commitdiff
Instantiate attributes when first building an instantiated
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 13 Jul 2010 00:16:40 +0000 (00:16 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 13 Jul 2010 00:16:40 +0000 (00:16 +0000)
VarDecl.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108218 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclBase.h
lib/AST/DeclBase.cpp
lib/Sema/SemaTemplateInstantiateDecl.cpp

index cc0124394b9dc1ca75cb61722f10ac2da062c06b..2d2407ffb18d67eeb49b29a056160d5c59ab5578 100644 (file)
@@ -312,7 +312,6 @@ public:
     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 {
index ddedc65a1bdb24a9c3e88a252b9dccc3752e7b03..d4f997de76691d26e8d1dd59f9c3a71c75a931ac 100644 (file)
@@ -372,18 +372,6 @@ void Decl::swapAttrs(Decl *RHS) {
   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) {
index 3a0e43672d14c45610af3a85e2d959f7e2cde328..2fd35285324e635eb57cfc95f73448884cf146a1 100644 (file)
@@ -396,11 +396,11 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) {
     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 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D,
       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)) {