[all-commits] [llvm/llvm-project] 588db1: [clangd] Use flags from open files when opening he...
Sam McCall via All-commits
all-commits at lists.llvm.org
Mon Mar 1 00:44:35 PST 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 588db1ccff713332c1f9358f423e682f18c06e8e
https://github.com/llvm/llvm-project/commit/588db1ccff713332c1f9358f423e682f18c06e8e
Author: Sam McCall <sam.mccall at gmail.com>
Date: 2021-03-01 (Mon, 01 Mar 2021)
Changed paths:
M clang-tools-extra/clangd/Headers.h
M clang-tools-extra/clangd/TUScheduler.cpp
M clang-tools-extra/clangd/TUScheduler.h
M clang-tools-extra/clangd/test/memory_tree.test
M clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
M clang/include/clang/Tooling/CompilationDatabase.h
M clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
M clang/unittests/Tooling/CompilationDatabaseTest.cpp
Log Message:
-----------
[clangd] Use flags from open files when opening headers they include
Currently our strategy for getting header compile flags is something like:
A) look for flags for the header in compile_commands.json
This basically never works, build systems don't generate this info.
B) try to match to an impl file in compile_commands.json and use its flags
This only (mostly) works if the headers are in the same project.
C) give up and use fallback flags
This kind of works for stdlib in the default configuration, and
otherwise doesn't.
Obviously there are big gaps here.
This patch inserts a new attempt between A and B: if the header is
transitively included by any open file (whether same project or not),
then we use its compile command.
This doesn't make any attempt to solve some related problems:
- parsing non-self-contained header files in context (importing PP state)
- using the compile flags of non-opened candidate files found in the index
Fixes https://github.com/clangd/clangd/issues/123
Fixes https://github.com/clangd/clangd/issues/695
See https://github.com/clangd/clangd/issues/519
Differential Revision: https://reviews.llvm.org/D97351
More information about the All-commits
mailing list