[llvm] [llvm][Tablegen][llvm-tblgen] Added keyword #undef to llvm-tblgen and fixed a small b… (PR #69135)

Jon Roelofs via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 17 10:05:50 PDT 2023


================
@@ -834,6 +830,24 @@ tgtok::TokKind TGLexer::lexPreprocessor(
       return tgtok::Error;
     }
 
+    return LexToken();
+  } else if (Kind == tgtok::Undef) {
+    StringRef MacroName = prepLexMacroName();
+    if (MacroName.empty())
+      return ReturnError(TokStart, "Expected macor name after #undef");
+
+    if (!DefinedMacros.erase(MacroName))
+      return ReturnError(TokStart, "undefine(#undef) an undefined macro");
----------------
jroelofs wrote:

In the C preprocessor, this case isn't an error. That may come as a surprise to folks trying to use this.

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


More information about the llvm-commits mailing list