[llvm] [TableGen] Allow empty terminator in SequenceToOffsetTable (PR #119751)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 12 13:33:30 PST 2024


================
@@ -127,10 +135,10 @@ class SequenceToOffsetTable {
   /// `\0`. Falls back to emitting a comma-separated integer list if
   /// `EmitLongStrLiterals` is false
   void emitStringLiteralDef(raw_ostream &OS, const Twine &Decl) const {
-    assert(Entries && "Call layout() before emitStringLiteralDef()");
+    assert(IsLaidOut && "Call layout() before emitStringLiteralDef()");
     if (!EmitLongStrLiterals) {
       OS << Decl << " = {\n";
-      emit(OS, printChar, "0");
+      emit(OS, printChar);
----------------
s-barannikov wrote:

The extra '\0' printing was added in https://reviews.llvm.org/D126136 and looks intentional. This way the generated data is the same regardless of EmitLongStrLiterals. If the option is enabled, the whole data is printed as a single string literal, and this string literal has an implicit terminating '\0' according to C. That change made the other case emit this extra '\0'.

It doesn't appear related to the issue with zero-sized arrays.


https://github.com/llvm/llvm-project/pull/119751


More information about the llvm-commits mailing list