Instantiate attributes when first building an instantiated

VarDecl.

llvm-svn: 108218
This commit is contained in:
Fariborz Jahanian 2010-07-13 00:16:40 +00:00
parent 6cc1df5d3d
commit f8681a2a3f
3 changed files with 3 additions and 19 deletions

View File

@ -312,7 +312,6 @@ public:
return getAttrsImpl(); // Uncommon case, out of line hash lookup. return getAttrsImpl(); // Uncommon case, out of line hash lookup.
} }
void swapAttrs(Decl *D); void swapAttrs(Decl *D);
void copyAttrs(Decl *D);
void invalidateAttrs(); void invalidateAttrs();
template<typename T> const T *getAttr() const { template<typename T> const T *getAttr() const {

View File

@ -372,18 +372,6 @@ void Decl::swapAttrs(Decl *RHS) {
RHS->HasAttrs = true; 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) { void Decl::Destroy(ASTContext &C) {
// Free attributes for this decl. // Free attributes for this decl.
if (HasAttrs) { if (HasAttrs) {

View File

@ -396,11 +396,11 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) {
Owner->makeDeclVisibleInContext(Var); Owner->makeDeclVisibleInContext(Var);
} else { } else {
Owner->addDecl(Var); Owner->addDecl(Var);
if (Owner->isFunctionOrMethod()) if (Owner->isFunctionOrMethod())
SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Var); SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Var);
} }
InstantiateAttrs(D, Var);
// Link instantiations of static data members back to the template from // Link instantiations of static data members back to the template from
// which they were instantiated. // which they were instantiated.
if (Var->isStaticDataMember()) if (Var->isStaticDataMember())
@ -2591,10 +2591,7 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D,
ParentDC->isFunctionOrMethod()) { ParentDC->isFunctionOrMethod()) {
// D is a local of some kind. Look into the map of local // D is a local of some kind. Look into the map of local
// declarations to their instantiations. // declarations to their instantiations.
NamedDecl *ND = return cast<NamedDecl>(CurrentInstantiationScope->getInstantiationOf(D));
cast<NamedDecl>(CurrentInstantiationScope->getInstantiationOf(D));
ND->copyAttrs(D);
return ND;
} }
if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(D)) { if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(D)) {