diff options
author | Sean Hunt <scshunt@csclub.uwaterloo.ca> | 2012-06-18 16:13:52 +0000 |
---|---|---|
committer | Sean Hunt <scshunt@csclub.uwaterloo.ca> | 2012-06-18 16:13:52 +0000 |
commit | 93f95f2a2cbb6bb3d17bfb5fc74ce1cccea751b6 (patch) | |
tree | 8240d49bcf20127ffff2af2652d8e4f29b147588 /lib/Sema/AttributeList.cpp | |
parent | adc6cbf5b502f1b58078455ab4fca66c7daac239 (diff) |
Handle C++11 attribute namespaces automatically.
Now, as long as the 'Namespaces' variable is correct inside Attr.td, the
generated code will correctly admit a C++11 attribute only when it has the
appropriate namespace(s).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158661 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/AttributeList.cpp')
-rw-r--r-- | lib/Sema/AttributeList.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/Sema/AttributeList.cpp b/lib/Sema/AttributeList.cpp index 8e7029350a..93f8c5d359 100644 --- a/lib/Sema/AttributeList.cpp +++ b/lib/Sema/AttributeList.cpp @@ -95,13 +95,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); } #include "clang/Sema/AttrParsedAttrKinds.inc" AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name, - const IdentifierInfo *ScopeName) { + const IdentifierInfo *ScopeName, + Syntax SyntaxUsed) { StringRef AttrName = Name->getName(); // Normalize the attribute name, __foo__ becomes foo. @@ -109,10 +111,14 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name, AttrName.size() >= 4) AttrName = AttrName.substr(2, AttrName.size() - 4); - // FIXME: implement attribute namespacing correctly. SmallString<64> Buf; if (ScopeName) - AttrName = ((Buf += ScopeName->getName()) += "___") += AttrName; - - return ::getAttrKind(AttrName); + 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); } |