diff options
author | Michael Han <fragmentshaders@gmail.com> | 2013-02-01 01:19:17 +0000 |
---|---|---|
committer | Michael Han <fragmentshaders@gmail.com> | 2013-02-01 01:19:17 +0000 |
commit | a31f65b10e61ca8f2f427b1df176c10ea8a0efa2 (patch) | |
tree | c3416c426c2000ccab355404bd726220c68d7381 /lib/Sema | |
parent | a55e3ff9cbb5ccf338abd15d60970d9655e46d55 (diff) |
[Sema][Attr]Fix alignment attribute printing.
Remove "IsMSDeclspec" argument from Align attribute since the arguments in Attr.td should
only model those appear in source code. Introduce attribute Accessor, and teach TableGen
to generate syntax kind accessors for Align attribute, and use those accessors to decide
if an alignment attribute is a declspec attribute.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174133 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 38 | ||||
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 4 |
2 files changed, 21 insertions, 21 deletions
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index cb6e898020..8500bff6bc 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -3315,30 +3315,28 @@ static void handleAlignedAttr(Sema &S, Decl *D, const AttributeList &Attr) { // ignored. if (Attr.getNumArgs() == 0) { - D->addAttr(::new (S.Context) AlignedAttr(Attr.getRange(), S.Context, - true, 0, Attr.isDeclspecAttribute(), - Attr.getAttributeSpellingListIndex())); + D->addAttr(::new (S.Context) AlignedAttr(Attr.getRange(), S.Context, + true, 0, Attr.getAttributeSpellingListIndex())); return; } - S.AddAlignedAttr(Attr.getRange(), D, Attr.getArg(0), - Attr.isDeclspecAttribute(), + S.AddAlignedAttr(Attr.getRange(), D, Attr.getArg(0), Attr.getAttributeSpellingListIndex()); } -void Sema::AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, - bool isDeclSpec, unsigned SpellingListIndex) { +void Sema::AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, + unsigned SpellingListIndex) { // FIXME: Handle pack-expansions here. if (DiagnoseUnexpandedParameterPack(E)) return; if (E->isTypeDependent() || E->isValueDependent()) { // Save dependent expressions in the AST to be instantiated. - D->addAttr(::new (Context) AlignedAttr(AttrRange, Context, true, E, - isDeclSpec, SpellingListIndex)); + D->addAttr(::new (Context) AlignedAttr(AttrRange, Context, true, E, + SpellingListIndex)); return; } - + SourceLocation AttrLoc = AttrRange.getBegin(); // FIXME: Cache the number on the Attr object? llvm::APSInt Alignment(32); @@ -3353,26 +3351,30 @@ void Sema::AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, << E->getSourceRange(); return; } - if (isDeclSpec) { + + AlignedAttr *Attr = ::new (Context) AlignedAttr(AttrRange, Context, true, + ICE.take(), + SpellingListIndex); + + if (Attr->isDeclspec()) { // We've already verified it's a power of 2, now let's make sure it's // 8192 or less. if (Alignment.getZExtValue() > 8192) { - Diag(AttrLoc, diag::err_attribute_aligned_greater_than_8192) + Diag(AttrLoc, diag::err_attribute_aligned_greater_than_8192) << E->getSourceRange(); return; } } - D->addAttr(::new (Context) AlignedAttr(AttrRange, Context, true, ICE.take(), - isDeclSpec, SpellingListIndex)); + D->addAttr(Attr); } -void Sema::AddAlignedAttr(SourceRange AttrRange, Decl *D, TypeSourceInfo *TS, - bool isDeclSpec, unsigned SpellingListIndex) { +void Sema::AddAlignedAttr(SourceRange AttrRange, Decl *D, TypeSourceInfo *TS, + unsigned SpellingListIndex) { // FIXME: Cache the number on the Attr object if non-dependent? // FIXME: Perform checking of type validity - D->addAttr(::new (Context) AlignedAttr(AttrRange, Context, false, TS, - isDeclSpec, SpellingListIndex)); + D->addAttr(::new (Context) AlignedAttr(AttrRange, Context, false, TS, + SpellingListIndex)); return; } diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index f5405ff383..c146e9dd44 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -79,8 +79,7 @@ void Sema::InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, ExprResult Result = SubstExpr(Aligned->getAlignmentExpr(), TemplateArgs); if (!Result.isInvalid()) - AddAlignedAttr(Aligned->getLocation(), New, Result.takeAs<Expr>(), - Aligned->getIsMSDeclSpec(), + AddAlignedAttr(Aligned->getLocation(), New, Result.takeAs<Expr>(), Aligned->getSpellingListIndex()); } else { TypeSourceInfo *Result = SubstType(Aligned->getAlignmentType(), @@ -89,7 +88,6 @@ void Sema::InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, DeclarationName()); if (Result) AddAlignedAttr(Aligned->getLocation(), New, Result, - Aligned->getIsMSDeclSpec(), Aligned->getSpellingListIndex()); } continue; |