[PATCH] D144654: [Lex] Warn when defining or undefining any builtin macro

John Brawn via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 13 10:47:27 PDT 2023


john.brawn added inline comments.


================
Comment at: clang/lib/Lex/PPDirectives.cpp:3189-3192
+    if ((MI->isBuiltinMacro() ||
+         SourceMgr.isWrittenInBuiltinFile(MI->getDefinitionLoc())) &&
+        !(getLangOpts().ObjC && isObjCProtectedMacro(II)))
+      Diag(MacroNameTok, diag::ext_pp_undef_builtin_macro);
----------------
aaron.ballman wrote:
> Should this diagnostic be suppressed in a system header on the assumption that system headers are part of the implementation and thus free to undefine/redefine macros at will?
It's already suppressed. ShowInSystemHeader in the Diagnostic tablegen class determines if a diagnostic is shown when it happens in a system header, and it's false by default for warnings.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144654/new/

https://reviews.llvm.org/D144654



More information about the cfe-commits mailing list