|
clang-tools 23.0.0git
|
Reads project module information directly from compile commands. More...
Public Member Functions | |
| CompileCommandsProjectModules (std::shared_ptr< const clang::tooling::CompilationDatabase > CDB, const ThreadsafeFS &TFS) | |
| std::vector< std::string > | getRequiredModules (PathRef File) override |
| std::string | getModuleNameForSource (PathRef File) override |
| ModuleNameState | getModuleNameState (llvm::StringRef ModuleName) override |
| std::string | getSourceForModuleName (llvm::StringRef ModuleName, PathRef RequiredSourceFile) override |
| void | setCommandMangler (CommandMangler Mangler) override |
| Public Member Functions inherited from clang::clangd::ProjectModules | |
| virtual | ~ProjectModules ()=default |
Additional Inherited Members | |
| Public Types inherited from clang::clangd::ProjectModules | |
| enum class | ModuleNameState { Unknown , Unique , Multiple } |
| using | CommandMangler |
Reads project module information directly from compile commands.
The key observation is that compile commands may already encode the mapping between a TU, the module names it imports, and the BMI paths it uses:
When that information is present, we can answer getSourceForModuleName(ModuleName, RequiredSourceFile) by first looking up the BMI path the consumer TU uses for ModuleName, and then mapping that BMI path back to the module unit source that produced it. This avoids the older scanning-only approach of guessing the module unit from the module name alone.
One subtle point is that producer commands alone do not reliably tell us the module name associated with a BMI path. In practice this backend learns that association from consumer -fmodule-file= entries, and then uses the BMI path to recover the producer source file. That is why indexing is built from both producer and consumer commands.
Note that compilation database can be stale, so results from this backend should be treated as preferred hints rather than unquestionable truth. The compound layer below validates or falls back when needed.
Definition at line 374 of file ProjectModules.cpp.
|
inline |
Definition at line 376 of file ProjectModules.cpp.
|
inlineoverridevirtual |
Implements clang::clangd::ProjectModules.
Definition at line 393 of file ProjectModules.cpp.
References clang::clangd::File, and clang::clangd::maybeCaseFoldPath().
|
inlineoverridevirtual |
Reimplemented from clang::clangd::ProjectModules.
Definition at line 402 of file ProjectModules.cpp.
References clang::clangd::ProjectModules::Multiple, clang::clangd::ProjectModules::Unique, and clang::clangd::ProjectModules::Unknown.
|
inlineoverridevirtual |
Implements clang::clangd::ProjectModules.
Definition at line 381 of file ProjectModules.cpp.
References clang::clangd::File.
|
inlineoverridevirtual |
Implements clang::clangd::ProjectModules.
Definition at line 411 of file ProjectModules.cpp.
References clang::clangd::maybeCaseFoldPath().
|
inlineoverridevirtual |
Reimplemented from clang::clangd::ProjectModules.
Definition at line 429 of file ProjectModules.cpp.