summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/AttributeList.cpp
diff options
context:
space:
mode:
authorAlexis Hunt <alercah@gmail.com>2012-06-18 16:13:52 +0000
committerAlexis Hunt <alercah@gmail.com>2012-06-18 16:13:52 +0000
commita0e54d453b843c424a0558cc1478b80ea3f4ab2b (patch)
tree3d242802f2a846194bf712206c5c9605ba7000a8 /clang/lib/Sema/AttributeList.cpp
parentb7c941bad9b77d1456c2f5d01fca58dd641a5c01 (diff)
downloadbcm5719-llvm-a0e54d453b843c424a0558cc1478b80ea3f4ab2b.tar.gz
bcm5719-llvm-a0e54d453b843c424a0558cc1478b80ea3f4ab2b.zip
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). llvm-svn: 158661
Diffstat (limited to 'clang/lib/Sema/AttributeList.cpp')
-rw-r--r--clang/lib/Sema/AttributeList.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/clang/lib/Sema/AttributeList.cpp b/clang/lib/Sema/AttributeList.cpp
index 8e7029350ab..93f8c5d3595 100644
--- a/clang/lib/Sema/AttributeList.cpp
+++ b/clang/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);
}
OpenPOWER on IntegriCloud