diff options
Diffstat (limited to 'lib/Sema/AttributeList.cpp')
-rw-r--r-- | lib/Sema/AttributeList.cpp | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/lib/Sema/AttributeList.cpp b/lib/Sema/AttributeList.cpp index f142ab4..0f209fd 100644 --- a/lib/Sema/AttributeList.cpp +++ b/lib/Sema/AttributeList.cpp @@ -12,9 +12,11 @@ //===----------------------------------------------------------------------===// #include "clang/Sema/AttributeList.h" +#include "clang/AST/ASTContext.h" #include "clang/AST/Expr.h" #include "clang/Basic/IdentifierTable.h" #include "llvm/ADT/StringSwitch.h" +#include "llvm/ADT/SmallString.h" using namespace clang; size_t AttributeList::allocated_size() const { @@ -94,10 +96,15 @@ AttributePool::createIntegerAttribute(ASTContext &C, IdentifierInfo *Name, SourceLocation TokLoc, int Arg) { Expr *IArg = IntegerLiteral::Create(C, llvm::APInt(32, (uint64_t) Arg), C.IntTy, TokLoc); - return create(Name, TokLoc, 0, TokLoc, 0, TokLoc, &IArg, 1, 0); + return create(Name, TokLoc, 0, TokLoc, 0, TokLoc, &IArg, 1, + AttributeList::AS_GNU); } -AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) { +#include "clang/Sema/AttrParsedAttrKinds.inc" + +AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name, + const IdentifierInfo *ScopeName, + Syntax SyntaxUsed) { StringRef AttrName = Name->getName(); // Normalize the attribute name, __foo__ becomes foo. @@ -105,22 +112,14 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) { AttrName.size() >= 4) AttrName = AttrName.substr(2, AttrName.size() - 4); - return llvm::StringSwitch<AttributeList::Kind>(AttrName) - #include "clang/Sema/AttrParsedAttrKinds.inc" - .Case("address_space", AT_address_space) - .Case("align", AT_aligned) // FIXME - should it be "aligned"? - .Case("base_check", AT_base_check) - .Case("bounded", IgnoredAttribute) // OpenBSD - .Case("__const", AT_const) // some GCC headers do contain this spelling - .Case("cf_returns_autoreleased", AT_cf_returns_autoreleased) - .Case("mode", AT_mode) - .Case("vec_type_hint", IgnoredAttribute) - .Case("ext_vector_type", AT_ext_vector_type) - .Case("neon_vector_type", AT_neon_vector_type) - .Case("neon_polyvector_type", AT_neon_polyvector_type) - .Case("opencl_image_access", AT_opencl_image_access) - .Case("objc_gc", AT_objc_gc) - .Case("objc_ownership", AT_objc_ownership) - .Case("vector_size", AT_vector_size) - .Default(UnknownAttribute); + SmallString<64> Buf; + if (ScopeName) + Buf += ScopeName->getName(); + // Ensure that in the case of C++11 attributes, we look for '::foo' if it is + // unscoped. + if (ScopeName || SyntaxUsed == AS_CXX11) + Buf += "::"; + Buf += AttrName; + + return ::getAttrKind(Buf); } |