[all-commits] [llvm/llvm-project] e8a64e: [clang][pp] adds '#pragma include_instead'
Christopher Di Bella via All-commits
all-commits at lists.llvm.org
Mon Jul 26 09:08:24 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e8a64e5491260714c79dab65d1aa73245931d314
https://github.com/llvm/llvm-project/commit/e8a64e5491260714c79dab65d1aa73245931d314
Author: Christopher Di Bella <cjdb at google.com>
Date: 2021-07-26 (Mon, 26 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
A clang/test/Preprocessor/Inputs/include_instead/bad-syntax.h
A clang/test/Preprocessor/Inputs/include_instead/file-not-found.h
A clang/test/Preprocessor/Inputs/include_instead/non-system-header.h
A clang/test/Preprocessor/Inputs/include_instead/private-x.h
A clang/test/Preprocessor/Inputs/include_instead/private1.h
A clang/test/Preprocessor/Inputs/include_instead/private2.h
A clang/test/Preprocessor/Inputs/include_instead/private3.h
A clang/test/Preprocessor/Inputs/include_instead/public-after.h
A clang/test/Preprocessor/Inputs/include_instead/public-before.h
A clang/test/Preprocessor/Inputs/include_instead/public-empty.h
A clang/test/Preprocessor/include_instead.cpp
A clang/test/Preprocessor/include_instead_file_not_found.cpp
Log Message:
-----------
[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
More information about the All-commits
mailing list