Instantiate attributes from the pattern record when instantiating
a class template. Fixes rdar://problem/8243419.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109967 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index d150369..ad96d7a 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -31,8 +31,6 @@
DeclContext *Owner;
const MultiLevelTemplateArgumentList &TemplateArgs;
- void InstantiateAttrs(Decl *Tmpl, Decl *New);
-
public:
typedef Sema::OwningExprResult OwningExprResult;
@@ -144,28 +142,29 @@
}
// FIXME: Is this still too simple?
-void TemplateDeclInstantiator::InstantiateAttrs(Decl *Tmpl, Decl *New) {
+void Sema::InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
+ Decl *Tmpl, Decl *New) {
for (const Attr *TmplAttr = Tmpl->getAttrs(); TmplAttr;
TmplAttr = TmplAttr->getNext()) {
// FIXME: This should be generalized to more than just the AlignedAttr.
if (const AlignedAttr *Aligned = dyn_cast<AlignedAttr>(TmplAttr)) {
if (Aligned->isDependent()) {
// The alignment expression is not potentially evaluated.
- EnterExpressionEvaluationContext Unevaluated(SemaRef,
+ EnterExpressionEvaluationContext Unevaluated(*this,
Action::Unevaluated);
- OwningExprResult Result = SemaRef.SubstExpr(Aligned->getAlignmentExpr(),
- TemplateArgs);
+ OwningExprResult Result = SubstExpr(Aligned->getAlignmentExpr(),
+ TemplateArgs);
if (!Result.isInvalid())
// FIXME: Is this the correct source location?
- SemaRef.AddAlignedAttr(Aligned->getAlignmentExpr()->getExprLoc(),
- New, Result.takeAs<Expr>());
+ AddAlignedAttr(Aligned->getAlignmentExpr()->getExprLoc(),
+ New, Result.takeAs<Expr>());
continue;
}
}
// FIXME: Is cloning correct for all attributes?
- Attr *NewAttr = TmplAttr->clone(SemaRef.Context);
+ Attr *NewAttr = TmplAttr->clone(Context);
New->addAttr(NewAttr);
}
}
@@ -234,7 +233,7 @@
Typedef->setPreviousDeclaration(cast<TypedefDecl>(InstPrev));
}
- InstantiateAttrs(D, Typedef);
+ SemaRef.InstantiateAttrs(TemplateArgs, D, Typedef);
Typedef->setAccess(D->getAccess());
Owner->addDecl(Typedef);
@@ -399,7 +398,7 @@
if (Owner->isFunctionOrMethod())
SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Var);
}
- InstantiateAttrs(D, Var);
+ SemaRef.InstantiateAttrs(TemplateArgs, D, Var);
// Link instantiations of static data members back to the template from
// which they were instantiated.
@@ -518,7 +517,7 @@
return 0;
}
- InstantiateAttrs(D, Field);
+ SemaRef.InstantiateAttrs(TemplateArgs, D, Field);
if (Invalid)
Field->setInvalidDecl();
@@ -1975,7 +1974,7 @@
Proto->getExtInfo()));
}
- InstantiateAttrs(Tmpl, New);
+ SemaRef.InstantiateAttrs(TemplateArgs, Tmpl, New);
return false;
}