From e50a60d7349de151bd2b06d85a79201ebc372d8a Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Tue, 6 Dec 2022 14:34:18 +0100 Subject: [PATCH] Quick fix to unbreak tblgen past 8ae18303f97d llvm/tools/llvm-objdump/llvm-objdump.cpp:128:38: error: constexpr variable 'ObjdumpInfoTable' must be initialized by a constant expression static constexpr opt::OptTable::Info ObjdumpInfoTable[] = { ^ ~ ObjdumpOpts.inc:30:45: note: non-constexpr function 'substr' cannot be used in a constant expression OPTION(prefix_0, llvm::StringRef("").substr(0), INPUT, Input, INVALID, INVALID, nullptr, 0, 0, nullptr, nullptr, nullptr) ^ --- llvm/utils/TableGen/OptParserEmitter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/utils/TableGen/OptParserEmitter.cpp b/llvm/utils/TableGen/OptParserEmitter.cpp index ebef5847f713..f8ddbefdcc59 100644 --- a/llvm/utils/TableGen/OptParserEmitter.cpp +++ b/llvm/utils/TableGen/OptParserEmitter.cpp @@ -54,9 +54,9 @@ static std::string getOptionSpelling(const Record &R) { static void emitNameUsingSpelling(raw_ostream &OS, const Record &R) { size_t PrefixLength; - OS << "llvm::StringRef("; + OS << "llvm::StringRef(&"; write_cstring(OS, StringRef(getOptionSpelling(R, PrefixLength))); - OS << ").substr(" << PrefixLength << ")"; + OS << '[' << PrefixLength << "])"; } class MarshallingInfo {