aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplateInstantiateDecl.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2010-06-25 03:22:07 +0000
committerChandler Carruth <chandlerc@gmail.com>2010-06-25 03:22:07 +0000
commit4ced79f0971592e6e7122037de69ee9ae534ce72 (patch)
treef864ce489d064cd88454414a40f8a527b873f3ca /lib/Sema/SemaTemplateInstantiateDecl.cpp
parentfba9e8f85b3043da0e045cd653bcba9b6c60e067 (diff)
Implement dependent alignment attribute support. This is a bit gross given the
current attribute system, but it is enough to handle class templates which specify parts of their alignment in terms of their template parameters. This also replaces the attributes test in SemaTemplate with one that actually tests working attributes instead of broken ones. I plan to add more tests here for non-dependent attributes in a subsequent patch. Thanks to John for walking me through some of this. =D git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106818 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r--lib/Sema/SemaTemplateInstantiateDecl.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 1b28579e61..06f38e88d5 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -143,14 +143,29 @@ bool TemplateDeclInstantiator::SubstQualifier(const TagDecl *OldDecl,
return false;
}
-// FIXME: Is this too simple?
+// FIXME: Is this still too simple?
void TemplateDeclInstantiator::InstantiateAttrs(Decl *Tmpl, Decl *New) {
- for (const Attr *TmplAttr = Tmpl->getAttrs(); TmplAttr;
+ 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,
+ Action::Unevaluated);
+
+ OwningExprResult Result = SemaRef.SubstExpr(Aligned->getAlignmentExpr(),
+ TemplateArgs);
+ if (!Result.isInvalid())
+ // FIXME: Is this the correct source location?
+ SemaRef.AddAlignedAttr(Aligned->getAlignmentExpr()->getExprLoc(),
+ New, Result.takeAs<Expr>());
+ continue;
+ }
+ }
+
// FIXME: Is cloning correct for all attributes?
Attr *NewAttr = TmplAttr->clone(SemaRef.Context);
-
New->addAttr(NewAttr);
}
}