[all-commits] [llvm/llvm-project] 43de86: Implement #pragma clang restrict_expansion

thegreatbeanz via All-commits all-commits at lists.llvm.org
Mon Aug 23 09:46:59 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 43de869d77f77eedf9f8760f94940a249d2b5a41
      https://github.com/llvm/llvm-project/commit/43de869d77f77eedf9f8760f94940a249d2b5a41
  Author: Chris Bieneman <chris.bieneman at me.com>
  Date:   2021-08-23 (Mon, 23 Aug 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/pedantic-macro-interplay.h
    A clang/test/Lexer/Inputs/unsafe-macro-2.h
    A clang/test/Lexer/Inputs/unsafe-macro.h
    A clang/test/Lexer/pedantic-macro-interplay.c
    A clang/test/Lexer/unsafe-macro.c

  Log Message:
  -----------
  Implement #pragma clang restrict_expansion

This patch adds `#pragma clang restrict_expansion ` 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

Reviewed By: aaron.ballman

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




More information about the All-commits mailing list