[all-commits] [llvm/llvm-project] 22e3f5: [Lex] Warn when defining or undefining any builtin...

john-brawn-arm via All-commits all-commits at lists.llvm.org
Wed May 17 03:50:59 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 22e3f587fd1ff97185014cb1ba723579ed2150d3
      https://github.com/llvm/llvm-project/commit/22e3f587fd1ff97185014cb1ba723579ed2150d3
  Author: John Brawn <john.brawn at arm.com>
  Date:   2023-05-17 (Wed, 17 May 2023)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/lib/Lex/PPDirectives.cpp
    M clang/test/Lexer/builtin_redef.c
    M clang/test/Preprocessor/macro-reserved.c
    M clang/test/Preprocessor/macro-reserved.cpp

  Log Message:
  -----------
  [Lex] Warn when defining or undefining any builtin macro

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, though we shouldn't warn on feature test
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.

Differential Revision: https://reviews.llvm.org/D144654




More information about the All-commits mailing list