Currently HeaderSearch only looks at SearchDir's passed into it, but in
addition to those paths headers can be relative to including file's directory.
This patch makes sure that is taken into account.
Paths
| Differential D63295
[clang][HeaderSearch] Shorten paths for includes in mainfile's directory ClosedPublic Authored by kadircet on Jun 13 2019, 12:38 PM.
Details
Summary Currently HeaderSearch only looks at SearchDir's passed into it, but in This patch makes sure that is taken into account.
Diff Detail
Event TimelineComment Actions I'm not an expert in this code, but it looks reasonable.
This revision is now accepted and ready to land.Jul 1 2019, 5:44 AM Comment Actions Discussed it offline, technically taking the main file directory into account when shorten the #include path would not break the compiler, but it may introduce issues violating the code style -- in clangd codebase, we prefer to use "#include "<subdir_under_clangd>/header.h" style, e.g. index/background.cc uses #include "index/Background.h", with this patch we will shorten the include as #include "background.h", so we don't count the the index/background.h as included (a new #include "background.h" will be inserted). One possible solution is that we could use the main file directory as a last fallback (if we are not able to shorten the #included path using any search-header directories, we try to use the main-file directory). kadircet marked 3 inline comments as done. Comment Actions
Comment Actions looks mostly good, a few nits.
Closed by commit rL365005: [clang][HeaderSearch] Shorten paths for includes in mainfile's directory (authored by kadircet). · Explain WhyJul 3 2019, 12:47 AM This revision was automatically updated to reflect the committed changes. kadircet marked an inline comment as done.
Revision Contents
Diff 207715 cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/unittests/Lex/HeaderSearchTest.cpp
clang-tools-extra/trunk/clang-include-fixer/IncludeFixer.cpp
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/Headers.h
clang-tools-extra/trunk/clangd/Headers.cpp
clang-tools-extra/trunk/clangd/IncludeFixer.cpp
clang-tools-extra/trunk/clangd/unittests/CodeCompleteTests.cpp
clang-tools-extra/trunk/clangd/unittests/HeadersTests.cpp
|