[Lex] Only warn on defining or undefining language-defined builtins
authorJohn Brawn <john.brawn@arm.com>
Thu, 1 Jun 2023 10:09:40 +0000 (11:09 +0100)
committerJohn Brawn <john.brawn@arm.com>
Thu, 1 Jun 2023 16:37:50 +0000 (17:37 +0100)
commit844e9534c6d99ddb6bada740839760fa24d17cb6
treef5c5909518f46407c62e773be7f0d0e68216b9d6
parent541f5c4a6db35870091dd15dfa09dde751229a17
[Lex] Only warn on defining or undefining language-defined builtins

D144654 made it so that we warn on any defining or undefining of
builtin macros. However the C and C++ standards only forbid the
defining or undefining of macros defined in the language standard
itself, but clang defines more macros than those and warning on those
may not be helpful.

Resolve this by only warning if the builtin macro name is the name of
a macro defined by the language. This is done in a way that removes
some of the existing checks, as those were made redundant by
restricting the warning in this way.

Differential Revision: https://reviews.llvm.org/D151741
clang/lib/Lex/PPDirectives.cpp
clang/test/Preprocessor/macro-reserved.c
clang/test/Preprocessor/undef-x86.c [new file with mode: 0644]