[all-commits] [llvm/llvm-project] 973de7: Revert "[clang][pp] adds '#pragma include_instead'"

Hans via All-commits all-commits at lists.llvm.org
Tue Jul 27 08:30:11 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 973de7185606a21fd5e9d5e8c014fbf898c0e72f
      https://github.com/llvm/llvm-project/commit/973de7185606a21fd5e9d5e8c014fbf898c0e72f
  Author: Hans Wennborg <hans at chromium.org>
  Date:   2021-07-27 (Tue, 27 Jul 2021)

  Changed paths:
    M clang/include/clang/Basic/DiagnosticLexKinds.td
    M clang/include/clang/Lex/HeaderSearch.h
    M clang/include/clang/Lex/Preprocessor.h
    M clang/include/clang/Lex/PreprocessorLexer.h
    M clang/lib/Lex/Lexer.cpp
    M clang/lib/Lex/PPDirectives.cpp
    M clang/lib/Lex/PPLexerChange.cpp
    M clang/lib/Lex/Pragma.cpp
    R clang/test/Preprocessor/Inputs/include_instead/bad-syntax.h
    R clang/test/Preprocessor/Inputs/include_instead/file-not-found.h
    R clang/test/Preprocessor/Inputs/include_instead/non-system-header.h
    R clang/test/Preprocessor/Inputs/include_instead/private-x.h
    R clang/test/Preprocessor/Inputs/include_instead/private1.h
    R clang/test/Preprocessor/Inputs/include_instead/private2.h
    R clang/test/Preprocessor/Inputs/include_instead/private3.h
    R clang/test/Preprocessor/Inputs/include_instead/public-after.h
    R clang/test/Preprocessor/Inputs/include_instead/public-before.h
    R clang/test/Preprocessor/Inputs/include_instead/public-empty.h
    R clang/test/Preprocessor/include_instead.cpp
    R clang/test/Preprocessor/include_instead_file_not_found.cpp

  Log Message:
  -----------
  Revert "[clang][pp] adds '#pragma include_instead'"

> `#pragma clang include_instead(<header>)` is a pragma that can be used
> by system headers (and only system headers) to indicate to a tool that
> the file containing said pragma is an implementation-detail header and
> should not be directly included by user code.
>
> The library alternative is very messy code that can be seen in the first
> diff of D106124, and we'd rather avoid that with something more
> universal.
>
> This patch takes the first step by warning a user when they include a
> detail header in their code, and suggests alternative headers that the
> user should include instead. Future work will involve adding a fixit to
> automate the process, as well as cleaning up modules diagnostics to not
> suggest said detail headers. Other tools, such as clangd can also take
> advantage of this pragma to add the correct user headers.
>
> Differential Revision: https://reviews.llvm.org/D106394

This caused compiler crashes in Chromium builds involving PCH and an include
directive with macro expansion, when Token::getLiteralData() returned null. See
the code review for details.

This reverts commit e8a64e5491260714c79dab65d1aa73245931d314.




More information about the All-commits mailing list