[llvm] e50a60d - Quick fix to unbreak tblgen past 8ae18303f97d

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 6 05:39:47 PST 2022


Author: Benjamin Kramer
Date: 2022-12-06T14:39:38+01:00
New Revision: e50a60d7349de151bd2b06d85a79201ebc372d8a

URL: https://github.com/llvm/llvm-project/commit/e50a60d7349de151bd2b06d85a79201ebc372d8a
DIFF: https://github.com/llvm/llvm-project/commit/e50a60d7349de151bd2b06d85a79201ebc372d8a.diff

LOG: 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("<input>").substr(0), INPUT, Input, INVALID, INVALID, nullptr, 0, 0, nullptr, nullptr, nullptr)
                                            ^

Added: 
    

Modified: 
    llvm/utils/TableGen/OptParserEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/OptParserEmitter.cpp b/llvm/utils/TableGen/OptParserEmitter.cpp
index ebef5847f7137..f8ddbefdcc596 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 {


        


More information about the llvm-commits mailing list