john.brawn created this revision. john.brawn added reviewers: erichkeane, aaron.ballman, rjmccall. Herald added a project: clang. john.brawn added a child revision: D31343: Add an attribute plugin example.
Currently square-bracket-style (CXX11/C2X) attribute names are normalised to start with :: if they don't have a namespace. This is a bit odd, as such names are rejected when parsing, so don't do this. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D76704 Files: clang/lib/Basic/Attributes.cpp clang/utils/TableGen/ClangAttrEmitter.cpp Index: clang/utils/TableGen/ClangAttrEmitter.cpp =================================================================== --- clang/utils/TableGen/ClangAttrEmitter.cpp +++ clang/utils/TableGen/ClangAttrEmitter.cpp @@ -3739,10 +3739,8 @@ for (const auto &S : GetFlattenedSpellings(Attr)) { const std::string &RawSpelling = S.name(); std::string Spelling; - if (S.variety() == "CXX11" || S.variety() == "C2x") { - Spelling += S.nameSpace(); - Spelling += "::"; - } + if (!S.nameSpace().empty()) + Spelling += S.nameSpace() + "::"; if (S.variety() == "GNU") Spelling += NormalizeGNUAttrSpelling(RawSpelling); else @@ -3815,12 +3813,12 @@ const std::string &Variety = S.variety(); if (Variety == "CXX11") { Matches = &CXX11; - Spelling += S.nameSpace(); - Spelling += "::"; + if (!S.nameSpace().empty()) + Spelling += S.nameSpace() + "::"; } else if (Variety == "C2x") { Matches = &C2x; - Spelling += S.nameSpace(); - Spelling += "::"; + if (!S.nameSpace().empty()) + Spelling += S.nameSpace() + "::"; } else if (Variety == "GNU") Matches = &GNU; else if (Variety == "Declspec") Index: clang/lib/Basic/Attributes.cpp =================================================================== --- clang/lib/Basic/Attributes.cpp +++ clang/lib/Basic/Attributes.cpp @@ -85,11 +85,8 @@ StringRef ScopeName = normalizeAttrScopeName(Scope, SyntaxUsed); StringRef AttrName = normalizeAttrName(Name, ScopeName, SyntaxUsed); - // Ensure that in the case of C++11 attributes, we look for '::foo' if it is - // unscoped. SmallString<64> FullName = ScopeName; - if (Scope || SyntaxUsed == AttributeCommonInfo::AS_CXX11 || - SyntaxUsed == AttributeCommonInfo::AS_C2x) + if (!ScopeName.empty()) FullName += "::"; FullName += AttrName;
Index: clang/utils/TableGen/ClangAttrEmitter.cpp =================================================================== --- clang/utils/TableGen/ClangAttrEmitter.cpp +++ clang/utils/TableGen/ClangAttrEmitter.cpp @@ -3739,10 +3739,8 @@ for (const auto &S : GetFlattenedSpellings(Attr)) { const std::string &RawSpelling = S.name(); std::string Spelling; - if (S.variety() == "CXX11" || S.variety() == "C2x") { - Spelling += S.nameSpace(); - Spelling += "::"; - } + if (!S.nameSpace().empty()) + Spelling += S.nameSpace() + "::"; if (S.variety() == "GNU") Spelling += NormalizeGNUAttrSpelling(RawSpelling); else @@ -3815,12 +3813,12 @@ const std::string &Variety = S.variety(); if (Variety == "CXX11") { Matches = &CXX11; - Spelling += S.nameSpace(); - Spelling += "::"; + if (!S.nameSpace().empty()) + Spelling += S.nameSpace() + "::"; } else if (Variety == "C2x") { Matches = &C2x; - Spelling += S.nameSpace(); - Spelling += "::"; + if (!S.nameSpace().empty()) + Spelling += S.nameSpace() + "::"; } else if (Variety == "GNU") Matches = &GNU; else if (Variety == "Declspec") Index: clang/lib/Basic/Attributes.cpp =================================================================== --- clang/lib/Basic/Attributes.cpp +++ clang/lib/Basic/Attributes.cpp @@ -85,11 +85,8 @@ StringRef ScopeName = normalizeAttrScopeName(Scope, SyntaxUsed); StringRef AttrName = normalizeAttrName(Name, ScopeName, SyntaxUsed); - // Ensure that in the case of C++11 attributes, we look for '::foo' if it is - // unscoped. SmallString<64> FullName = ScopeName; - if (Scope || SyntaxUsed == AttributeCommonInfo::AS_CXX11 || - SyntaxUsed == AttributeCommonInfo::AS_C2x) + if (!ScopeName.empty()) FullName += "::"; FullName += AttrName;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits