summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorMichael Han <fragmentshaders@gmail.com>2013-02-01 01:19:17 +0000
committerMichael Han <fragmentshaders@gmail.com>2013-02-01 01:19:17 +0000
commitaf02bbe84f653125d50bfded5f854baf48c307f9 (patch)
treeb39061a7071ee992e3ce68b7f0ce9945833d2519 /clang/lib
parentc79cdff1959fb3e54ad3d24c18ecfb9f5b4b1c76 (diff)
downloadbcm5719-llvm-af02bbe84f653125d50bfded5f854baf48c307f9.tar.gz
bcm5719-llvm-af02bbe84f653125d50bfded5f854baf48c307f9.zip
[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. llvm-svn: 174133
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp38
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiateDecl.cpp4
2 files changed, 21 insertions, 21 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index cb6e898020c..8500bff6bcb 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/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/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index f5405ff383b..c146e9dd449 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/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;
OpenPOWER on IntegriCloud