|
20 | 20 | #include "llvm/ADT/STLExtras.h" |
21 | 21 | #include "llvm/ADT/SmallString.h" |
22 | 22 | #include "llvm/ADT/StringExtras.h" |
| 23 | +#include "llvm/ADT/StringMap.h" |
23 | 24 | #include "llvm/ADT/StringRef.h" |
24 | 25 | #include "llvm/ADT/StringSwitch.h" |
25 | 26 | #include "llvm/Support/ErrorHandling.h" |
@@ -3667,6 +3668,9 @@ static bool GenerateTargetSpecificAttrChecks(const Record *R, |
3667 | 3668 | static void GenerateHasAttrSpellingStringSwitch( |
3668 | 3669 | ArrayRef<std::pair<const Record *, FlattenedSpelling>> Attrs, |
3669 | 3670 | raw_ostream &OS, StringRef Variety, StringRef Scope = "") { |
| 3671 | + |
| 3672 | + llvm::StringMap<std::string> TestStringMap; |
| 3673 | + |
3670 | 3674 | for (const auto &[Attr, Spelling] : Attrs) { |
3671 | 3675 | // C++11-style attributes have specific version information associated with |
3672 | 3676 | // them. If the attribute has no scope, the version information must not |
@@ -3727,12 +3731,24 @@ static void GenerateHasAttrSpellingStringSwitch( |
3727 | 3731 | } |
3728 | 3732 | } |
3729 | 3733 |
|
3730 | | - std::string TestStr = !Test.empty() |
3731 | | - ? Test + " ? " + itostr(Version) + " : 0" |
3732 | | - : itostr(Version); |
3733 | | - if (Scope.empty() || Scope == Spelling.nameSpace()) |
3734 | | - OS << " .Case(\"" << Spelling.name() << "\", " << TestStr << ")\n"; |
| 3734 | + std::string TestStr = |
| 3735 | + !Test.empty() ? '(' + Test + " ? " + itostr(Version) + " : 0" + ')' |
| 3736 | + : '(' + itostr(Version) + ')'; |
| 3737 | + |
| 3738 | + if (Scope.empty() || Scope == Spelling.nameSpace()) { |
| 3739 | + if (TestStringMap.contains(Spelling.name())) { |
| 3740 | + TestStringMap[Spelling.name()] += " || " + TestStr; |
| 3741 | + } else { |
| 3742 | + TestStringMap[Spelling.name()] = TestStr; |
| 3743 | + } |
| 3744 | + } |
| 3745 | + } |
| 3746 | + |
| 3747 | + for (auto &entry : TestStringMap) { |
| 3748 | + OS << " .Case(\"" << entry.getKey() << "\", " << entry.getValue() |
| 3749 | + << ")\n"; |
3735 | 3750 | } |
| 3751 | + |
3736 | 3752 | OS << " .Default(0);\n"; |
3737 | 3753 | } |
3738 | 3754 |
|
|
0 commit comments