diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2013-11-04 12:55:56 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2013-11-04 12:55:56 +0000 |
commit | 4768b3179738c723bbab66b100a26f05457f9a87 (patch) | |
tree | b3abedb65bde3431f769afb870625a6fe31ae9bd /clang/lib/Parse/ParseDecl.cpp | |
parent | 46eeaba93bf84e19b8e6c7d0a251dd1c2bc4789d (diff) | |
download | bcm5719-llvm-4768b3179738c723bbab66b100a26f05457f9a87.tar.gz bcm5719-llvm-4768b3179738c723bbab66b100a26f05457f9a87.zip |
Attributes which accept a type as their sole argument are no longer hard coded into the parser. Instead, they are automatically listed through tablegen.
llvm-svn: 193989
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 27b4919b342..c5904933133 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -181,16 +181,27 @@ void Parser::ParseGNUAttributes(ParsedAttributes &attrs, } } -/// \brief Determine whether the given attribute has an identifier argument. -static bool attributeHasIdentifierArg(const IdentifierInfo &II) { - StringRef Name = II.getName(); +/// \brief Normalizes an attribute name by dropping prefixed and suffixed __. +static StringRef normalizeAttrName(StringRef Name) { if (Name.size() >= 4 && Name.startswith("__") && Name.endswith("__")) Name = Name.drop_front(2).drop_back(2); - return llvm::StringSwitch<bool>(Name) + return Name; +} + +/// \brief Determine whether the given attribute has an identifier argument. +static bool attributeHasIdentifierArg(const IdentifierInfo &II) { + return llvm::StringSwitch<bool>(normalizeAttrName(II.getName())) #include "clang/Parse/AttrIdentifierArg.inc" .Default(false); } +/// \brief Determine whether the given attribute parses a type argument. +static bool attributeIsTypeArgAttr(const IdentifierInfo &II) { + return llvm::StringSwitch<bool>(normalizeAttrName(II.getName())) +#include "clang/Parse/AttrTypeArg.inc" + .Default(false); +} + IdentifierLoc *Parser::ParseIdentifierLoc() { assert(Tok.is(tok::identifier) && "expected an identifier"); IdentifierLoc *IL = IdentifierLoc::create(Actions.Context, @@ -260,9 +271,8 @@ void Parser::ParseGNUAttributeArgs(IdentifierInfo *AttrName, ParseTypeTagForDatatypeAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc); return; } - // __attribute__((vec_type_hint)) and iboutletcollection expect a type arg. - if (AttrKind == AttributeList::AT_VecTypeHint || - AttrKind == AttributeList::AT_IBOutletCollection) { + // Some attributes expect solely a type parameter. + if (attributeIsTypeArgAttr(*AttrName)) { ParseAttributeWithTypeArg(*AttrName, AttrNameLoc, Attrs, EndLoc); return; } |