diff options
author | Sean Hunt <scshunt@csclub.uwaterloo.ca> | 2010-08-18 23:23:40 +0000 |
---|---|---|
committer | Sean Hunt <scshunt@csclub.uwaterloo.ca> | 2010-08-18 23:23:40 +0000 |
commit | cf807c4dfdb23e8fa3f400e0b24ef5b79db7a530 (patch) | |
tree | a4ad221a821125e6a865fe554a9bdd7305fa4706 /lib/Sema/SemaAttr.cpp | |
parent | ea94bbc4769697143e717df9b0310f874102b6c1 (diff) |
Generate Attr subclasses with TableGen.
Now all classes derived from Attr are generated from TableGen.
Additionally, Attr* is no longer its own linked list; SmallVectors or
Attr* are used. The accompanying LLVM commit contains the updates to
TableGen necessary for this.
Some other notes about newly-generated attribute classes:
- The constructor arguments are a SourceLocation and a Context&,
followed by the attributes arguments in the order that they were
defined in Attr.td
- Every argument in Attr.td has an appropriate accessor named getFoo,
and there are sometimes a few extra ones (such as to get the length
of a variadic argument).
Additionally, specific_attr_iterator has been introduced, which will
iterate over an AttrVec, but only over attributes of a certain type. It
can be accessed through either Decl::specific_attr_begin/end or
the global functions of the same name.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111455 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaAttr.cpp')
-rw-r--r-- | lib/Sema/SemaAttr.cpp | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/lib/Sema/SemaAttr.cpp b/lib/Sema/SemaAttr.cpp index 96793d5a40..66d31dda9f 100644 --- a/lib/Sema/SemaAttr.cpp +++ b/lib/Sema/SemaAttr.cpp @@ -14,6 +14,7 @@ #include "clang/Sema/Sema.h" #include "clang/Sema/Lookup.h" +#include "clang/AST/Attr.h" #include "clang/AST/Expr.h" #include "clang/Basic/TargetInfo.h" #include "clang/Lex/Preprocessor.h" @@ -120,9 +121,11 @@ void Sema::AddAlignmentAttributesForRecord(RecordDecl *RD) { // Otherwise, check to see if we need a max field alignment attribute. if (unsigned Alignment = Stack->getAlignment()) { if (Alignment == PackStackEntry::kMac68kAlignmentSentinel) - RD->addAttr(::new (Context) AlignMac68kAttr()); + RD->addAttr(::new (Context) AlignMac68kAttr(SourceLocation(), Context)); else - RD->addAttr(::new (Context) MaxFieldAlignmentAttr(Alignment * 8)); + RD->addAttr(::new (Context) MaxFieldAlignmentAttr(SourceLocation(), + Context, + Alignment * 8)); } } @@ -285,11 +288,12 @@ void Sema::ActOnPragmaUnused(const Token *Identifiers, unsigned NumIdentifiers, continue; } - VD->addAttr(::new (Context) UnusedAttr()); + VD->addAttr(::new (Context) UnusedAttr(Tok.getLocation(), Context)); } } -typedef std::vector<VisibilityAttr::VisibilityTypes> VisStack; +typedef std::vector<std::pair<VisibilityAttr::VisibilityType, + SourceLocation> > VisStack; void Sema::AddPushedVisibilityAttribute(Decl *D) { if (!VisContext) @@ -299,9 +303,10 @@ void Sema::AddPushedVisibilityAttribute(Decl *D) { return; VisStack *Stack = static_cast<VisStack*>(VisContext); - VisibilityAttr::VisibilityTypes type = Stack->back(); + VisibilityAttr::VisibilityType type = Stack->back().first; + SourceLocation loc = Stack->back().second; - D->addAttr(::new (Context) VisibilityAttr(type, true)); + D->addAttr(::new (Context) VisibilityAttr(loc, Context, type)); } /// FreeVisContext - Deallocate and null out VisContext. @@ -314,33 +319,34 @@ void Sema::ActOnPragmaVisibility(bool IsPush, const IdentifierInfo* VisType, SourceLocation PragmaLoc) { if (IsPush) { // Compute visibility to use. - VisibilityAttr::VisibilityTypes type; + VisibilityAttr::VisibilityType type; if (VisType->isStr("default")) - type = VisibilityAttr::DefaultVisibility; + type = VisibilityAttr::Default; else if (VisType->isStr("hidden")) - type = VisibilityAttr::HiddenVisibility; + type = VisibilityAttr::Hidden; else if (VisType->isStr("internal")) - type = VisibilityAttr::HiddenVisibility; // FIXME + type = VisibilityAttr::Hidden; // FIXME else if (VisType->isStr("protected")) - type = VisibilityAttr::ProtectedVisibility; + type = VisibilityAttr::Protected; else { Diag(PragmaLoc, diag::warn_attribute_unknown_visibility) << VisType->getName(); return; } - PushPragmaVisibility(type); + PushPragmaVisibility(type, PragmaLoc); } else { PopPragmaVisibility(); } } -void Sema::PushPragmaVisibility(VisibilityAttr::VisibilityTypes type) { +void Sema::PushPragmaVisibility(VisibilityAttr::VisibilityType type, + SourceLocation loc) { // Put visibility on stack. if (!VisContext) VisContext = new VisStack; VisStack *Stack = static_cast<VisStack*>(VisContext); - Stack->push_back(type); + Stack->push_back(std::make_pair(type, loc)); } void Sema::PopPragmaVisibility() { |