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

john-brawn-arm via All-commits all-commits at lists.llvm.org
Thu May 25 04:00:43 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0123deb3a6f0a83095287f51b07c77b7b43ab847
      https://github.com/llvm/llvm-project/commit/0123deb3a6f0a83095287f51b07c77b7b43ab847
  Author: John Brawn <john.brawn at arm.com>
  Date:   2023-05-25 (Thu, 25 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