[clang] [clang][TableGen] Fix Duplicate Entries in TableGen (PR #140828)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed May 21 04:58:32 PDT 2025
================
@@ -3727,12 +3734,26 @@ static void GenerateHasAttrSpellingStringSwitch(
}
}
- std::string TestStr = !Test.empty()
- ? Test + " ? " + itostr(Version) + " : 0"
- : itostr(Version);
- if (Scope.empty() || Scope == Spelling.nameSpace())
- OS << " .Case(\"" << Spelling.name() << "\", " << TestStr << ")\n";
+ std::string TestStr =
+ !Test.empty() ? '(' + Test + " ? " + itostr(Version) + " : 0" + ')'
+ : '(' + itostr(Version) + ')';
+
+ if (Scope.empty() || Scope == Spelling.nameSpace()) {
+ if (TestStringMap.contains(Spelling.name())) {
+ TestStringMap[Spelling.name()] += " || " + TestStr;
+ } else {
+ TestStringMap[Spelling.name()] = TestStr;
+ }
+ }
+ }
+
+ // Create the actual string switch statement after all the attributes have
+ // been parsed
+ for (auto &entry : TestStringMap) {
+ OS << " .Case(\"" << entry.getKey() << "\", " << entry.getValue()
+ << ")\n";
----------------
AaronBallman wrote:
```suggestion
for (auto &Entry : TestStringMap) {
OS << " .Case(\"" << Entry.getKey() << "\", " << Entry.getValue()
<< ")\n";
```
https://github.com/llvm/llvm-project/pull/140828
More information about the cfe-commits
mailing list