================ @@ -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 = ---------------- Mr-Anyone wrote:
Take the `interrupt` attribute as an example: This is the original string: `true && (T.getArch() == llvm::Triple::riscv32 || T.getArch() == llvm::Triple::riscv64) ? 1 : 0`. The problem is that there are multiple of them for a single attribute, such as `true && (T.getArch() == llvm::Triple::arm || T.getArch() == llvm::Triple::thumb || T.getArch() == llvm::Triple::armeb || T.getArch() == llvm::Triple::thumbeb) ? 1 : 0 ` for arm. Meaning that, we used to get: ``` .Case("interrupt",true && (T.getArch() == llvm::Triple::riscv32 || T.getArch() == llvm::Triple::riscv64) ? 1 : 0 ) .Case("interrupt",true && (T.getArch() == llvm::Triple::arm || T.getArch() == llvm::Triple::thumb || T.getArch() == llvm::Triple::armeb || T.getArch() == llvm::Triple::thumbeb) ? 1 : 0 ... ``` This is the new one `TestStr`: `(true && (T.getArch() == llvm::Triple::avr) ? 1 : 0)`, with the only difference being the added parentheses. We can join test strings together with `||`, meaning we generate something like this: ``` (true && (T.getArch() == llvm::Triple::riscv32 || T.getArch() == llvm::Triple::riscv64) ? 1 : 0) || (true && (T.getArch() == llvm::Triple::arm || T.getArch() == llvm::Triple::thumb || T.getArch() == llvm::Triple::armeb || T.getArch() == llvm::Triple::thumbeb) ? 1 : 0) ... ``` So now we have a single case statement instead, ``` .Case("interrupt",(true && (T.getArch() == llvm::Triple::riscv32 || T.getArch() == llvm::Triple::riscv64) ? 1 : 0) || (true && (T.getArch() == llvm::Triple::arm || T.getArch() == llvm::Triple::thumb || T.getArch() == llvm::Triple::armeb || T.getArch() == llvm::Triple::thumbeb) ? 1 : 0) ... ) ... ``` https://github.com/llvm/llvm-project/pull/140828 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits