[all-commits] [llvm/llvm-project] 393e6e: Support macro deprecation #pragma clang deprecated

thegreatbeanz via All-commits all-commits at lists.llvm.org
Thu Jul 29 09:24:48 PDT 2021


  Branch: refs/heads/beanz/final-macro
  Home:   https://github.com/llvm/llvm-project
  Commit: 393e6e4cbc05f589c4dd75dbfae79ee44eb1a5f5
      https://github.com/llvm/llvm-project/commit/393e6e4cbc05f589c4dd75dbfae79ee44eb1a5f5
  Author: Chris Bieneman <chris.bieneman at me.com>
  Date:   2021-07-29 (Thu, 29 Jul 2021)

  Changed paths:
    M clang/docs/LanguageExtensions.rst
    M clang/include/clang/Basic/DiagnosticGroups.td
    M clang/include/clang/Basic/DiagnosticLexKinds.td
    M clang/include/clang/Basic/IdentifierTable.h
    M clang/include/clang/Lex/Preprocessor.h
    M clang/lib/Lex/PPDirectives.cpp
    M clang/lib/Lex/PPExpressions.cpp
    M clang/lib/Lex/PPMacroExpansion.cpp
    M clang/lib/Lex/Pragma.cpp
    M clang/lib/Lex/Preprocessor.cpp
    A clang/test/Lexer/deprecate-macro.c

  Log Message:
  -----------
  Support macro deprecation #pragma clang deprecated

This patch adds `#pragma clang deprecated` to enable deprecation of
preprocessor macros.

The macro must be defined before `#pragma clang deprecated`. When
deprecating a macro a custom message may be optionally provided.

Warnings are emitted at the use site of a deprecated macro, and can be
controlled via the `-Wdeprecated` warning group.

This patch takes some rough inspiration and a few lines of code from
https://reviews.llvm.org/D67935.

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


  Commit: 997d9222f2ffa08c646076f2154993484e1ade98
      https://github.com/llvm/llvm-project/commit/997d9222f2ffa08c646076f2154993484e1ade98
  Author: Chris Bieneman <chris.bieneman at me.com>
  Date:   2021-07-29 (Thu, 29 Jul 2021)

  Changed paths:
    M clang/docs/LanguageExtensions.rst
    M clang/include/clang/Basic/DiagnosticGroups.td
    M clang/include/clang/Basic/DiagnosticLexKinds.td
    M clang/include/clang/Basic/IdentifierTable.h
    M clang/include/clang/Lex/Preprocessor.h
    M clang/lib/Lex/Pragma.cpp
    M clang/lib/Lex/Preprocessor.cpp
    A clang/test/Lexer/Inputs/unsafe-macro-2.h
    A clang/test/Lexer/Inputs/unsafe-macro.h
    A clang/test/Lexer/unsafe-macro.c

  Log Message:
  -----------
  This patch adds `#pragma clang header_unsafe` to enable flagging macros
as unsafe for header use. This is to allow macros that may have ABI
implications to be avoided in headers that have ABI stability promises.

Using macros in headers (particularly public headers) can cause a
variety of issues relating to ABI and modules. This new pragma logs
warnings when using annotated macros outside the main source file.

This warning is added under a new diagnostics group -Wpedantic-macros.


  Commit: 267dc10d53f124dceeccee042f61e6e6624f6d4c
      https://github.com/llvm/llvm-project/commit/267dc10d53f124dceeccee042f61e6e6624f6d4c
  Author: Chris Bieneman <chris.bieneman at me.com>
  Date:   2021-07-29 (Thu, 29 Jul 2021)

  Changed paths:
    M clang/docs/LanguageExtensions.rst
    M clang/include/clang/Basic/DiagnosticGroups.td
    M clang/include/clang/Basic/DiagnosticLexKinds.td
    M clang/include/clang/Basic/IdentifierTable.h
    M clang/lib/Lex/PPDirectives.cpp
    M clang/lib/Lex/Pragma.cpp
    A clang/test/Lexer/final-macro.c

  Log Message:
  -----------
  Implement #pragma clang final extension

This patch adds a new preprocessor extension ``#pragma clang final``
which enables warning on undefinition and re-definition of macros.

The intent of this warning is to extend beyond ``-Wmacro-redefined`` to
warn against any and all alterations to macros that are marked `final`.

This warning is part of the ``-Wpedantic-macros`` diagnostics group.


Compare: https://github.com/llvm/llvm-project/compare/393e6e4cbc05%5E...267dc10d53f1


More information about the All-commits mailing list