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

John Brawn via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 23 09:24:41 PST 2023


john.brawn created this revision.
john.brawn added reviewers: rsmith, jansvoboda11, rjmccall.
Herald added a project: All.
john.brawn requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Currently we warn when MI->isBuiltinMacro, but this is only true for builtin macros that require processing when expanding. Checking SourceMgr.isWrittenInBuiltinFile in addition to this will mean that we catch all builtin macros.

As part of doing this I've also moved the handling of undefining from CheckMacroName to HandleUndefDirective, as it doesn't really make sense to handle undefining in CheckMacroName but defining in HandleDefineDirective. It would be nice to instead handle both in CheckMacroName, but that isn't possible as the handling of defines requires looking at what the name is being defined to.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144654

Files:
  clang/lib/Lex/PPDirectives.cpp
  clang/test/Preprocessor/macro-reserved.c
  clang/test/Preprocessor/macro-reserved.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144654.499888.patch
Type: text/x-patch
Size: 4030 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230223/4d8e73f4/attachment.bin>


More information about the cfe-commits mailing list