[llvm] [TableGen] Detect invalid -D arguments and fail. (PR #102813)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 12 10:11:46 PDT 2024


================
@@ -54,9 +76,16 @@ TGLexer::TGLexer(SourceMgr &SM, ArrayRef<std::string> Macros) : SrcMgr(SM) {
   PrepIncludeStack.push_back(
       std::make_unique<std::vector<PreprocessorControlDesc>>());
 
-  // Put all macros defined in the command line into the DefinedMacros set.
-  for (const std::string &MacroName : Macros)
+  // Add all macros defined on the command line to the DefinedMacros set.
+  // Check invalid macro names and print fatal error if we find one.
+  for (StringRef MacroName : Macros) {
+    const char *End = lexMacroName(MacroName);
+    if (End != MacroName.end())
+      PrintFatalError("Invalid macro name `" + MacroName +
+                      "` specified on command line.");
----------------
jurahul wrote:

I've removed the .

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


More information about the llvm-commits mailing list