Add a new attribute definition spelling, Clang<"attr">, that expands to two attribute spellings: GNU<"attr"> and CXX11<"clang", "attr">. This is similar to how the GCC spelling works and is intended to be used for attributes introduced for Clang.
Changes all existing attributes that currently use GNU<"attr"> and CXX11<"clang", "attr> spellings to instead use the Clang<"attr"> spelling.
No additional tests are necessary because the existing tests already use both spellings for the attributes converted to the new spelling. No functional changes are expected.
llvm-svn: 316658
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index effabcc..9284fe4 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -56,8 +56,8 @@
V(Spelling.getValueAsString("Variety")),
N(Spelling.getValueAsString("Name")) {
- assert(V != "GCC" && "Given a GCC spelling, which means this hasn't been"
- "flattened!");
+ assert(V != "GCC" && V != "Clang" &&
+ "Given a GCC spelling, which means this hasn't been flattened!");
if (V == "CXX11" || V == "C2x" || V == "Pragma")
NS = Spelling.getValueAsString("Namespace");
bool Unset;
@@ -78,11 +78,15 @@
std::vector<FlattenedSpelling> Ret;
for (const auto &Spelling : Spellings) {
- if (Spelling->getValueAsString("Variety") == "GCC") {
+ StringRef Variety = Spelling->getValueAsString("Variety");
+ StringRef Name = Spelling->getValueAsString("Name");
+ if (Variety == "GCC") {
// Gin up two new spelling objects to add into the list.
- Ret.emplace_back("GNU", Spelling->getValueAsString("Name"), "", true);
- Ret.emplace_back("CXX11", Spelling->getValueAsString("Name"), "gnu",
- true);
+ Ret.emplace_back("GNU", Name, "", true);
+ Ret.emplace_back("CXX11", Name, "gnu", true);
+ } else if (Variety == "Clang") {
+ Ret.emplace_back("GNU", Name, "", false);
+ Ret.emplace_back("CXX11", Name, "clang", false);
} else
Ret.push_back(FlattenedSpelling(*Spelling));
}