[llvm] [NFC][TableGen] Emit more readable builtin string table. (PR #105445)
Sergei Barannikov via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 22 06:18:23 PDT 2024
================
@@ -52,6 +52,33 @@ class StringToOffsetTable {
return II->second;
}
+ // Emit the string using string literal concatenation, for better readability
+ // and searchability.
+ void EmitStringLiteralDef(raw_ostream &OS, const Twine &Decl,
+ const Twine &Indent = " ") const {
+ OS << "\n"
+ << Indent << "#ifdef __GNUC__\n"
+ << Indent << "#pragma GCC diagnostic push\n"
+ << Indent << "#pragma GCC diagnostic ignored \"-Woverlength-strings\"\n"
+ << Indent << "#endif\n"
+ << Indent << Decl << " = {\n";
----------------
s-barannikov wrote:
> I guess you mean inline the pragma emission in IntrinsicEmitter?
What I meant is that the call site should look like:
```
OS << " static constexpr char BuiltinNames[] = \n";
Table.EmitStringAsFragments(OS);
OS << ";\n\n";
```
I didn't consider pragmas.
I now see that SequenceToOffsetTable works similar to your implementation, so I think it is fine to keep them aligned.
https://github.com/llvm/llvm-project/pull/105445
More information about the llvm-commits
mailing list