Go to the documentation of this file.
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_GLOBALCOMPILATIONDATABASE_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_GLOBALCOMPILATIONDATABASE_H
15 #include "clang/Tooling/ArgumentsAdjusters.h"
16 #include "clang/Tooling/CompilationDatabase.h"
17 #include "llvm/ADT/Optional.h"
18 #include "llvm/ADT/StringMap.h"
40 virtual llvm::Optional<tooling::CompileCommand>
70 llvm::Optional<Path> CompileCommandsDir);
76 llvm::Optional<tooling::CompileCommand>
87 std::unique_ptr<clang::tooling::CompilationDatabase> CDB =
nullptr;
88 bool SentBroadcast =
false;
92 struct CDBLookupRequest {
95 bool ShouldBroadcast =
false;
97 struct CDBLookupResult {
98 tooling::CompilationDatabase *CDB =
nullptr;
101 llvm::Optional<CDBLookupResult> lookupCDB(CDBLookupRequest Request)
const;
104 void broadcastCDB(CDBLookupResult Res)
const;
106 mutable std::mutex Mutex;
108 mutable llvm::StringMap<CachedCDB> CompilationDatabases;
112 llvm::Optional<Path> CompileCommandsDir;
118 std::unique_ptr<GlobalCompilationDatabase>
120 std::unique_ptr<GlobalCompilationDatabase>
Base);
130 std::vector<std::string> FallbackFlags = {},
131 tooling::ArgumentsAdjuster Adjuster =
nullptr);
133 llvm::Optional<tooling::CompileCommand>
143 llvm::Optional<tooling::CompileCommand> CompilationCommand);
146 mutable std::mutex Mutex;
147 llvm::StringMap<tooling::CompileCommand> Commands;
149 tooling::ArgumentsAdjuster ArgsAdjuster;
150 std::vector<std::string> FallbackFlags;
151 CommandChanged::Subscription BaseChanged;
157 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_GLOBALCOMPILATIONDATABASE_H
~DirectoryBasedGlobalCompilationDatabase() override
std::unique_ptr< GlobalCompilationDatabase > Base
OverlayCDB(const GlobalCompilationDatabase *Base, std::vector< std::string > FallbackFlags={}, tooling::ArgumentsAdjuster Adjuster=nullptr)
std::string Path
A typedef to represent a file path.
llvm::Optional< tooling::CompileCommand > getCompileCommand(PathRef File) const override
Scans File's parents looking for compilation databases.
llvm::Optional< tooling::CompileCommand > getCompileCommand(PathRef File) const override
If there are any known-good commands for building this file, returns one.
llvm::Optional< ProjectInfo > getProjectInfo(PathRef File) const override
Returns the path to first directory containing a compilation database in File's parents.
llvm::Optional< ProjectInfo > getProjectInfo(PathRef File) const override
Project info is gathered purely from the inner compilation database to ensure consistency.
Documents should not be synced at all.
virtual llvm::Optional< tooling::CompileCommand > getCompileCommand(PathRef File) const =0
If there are any known-good commands for building this file, returns one.
Provides compilation arguments used for parsing C and C++ files.
Subscription observe(Listener L)
DirectoryBasedGlobalCompilationDatabase(llvm::Optional< Path > CompileCommandsDir)
tooling::CompileCommand getFallbackCommand(PathRef File) const override
Makes a guess at how to build a file.
virtual tooling::CompileCommand getFallbackCommand(PathRef File) const
Makes a guess at how to build a file.
virtual ~GlobalCompilationDatabase()=default
std::function< void(const std::vector< std::string > &)> Listener
std::unique_ptr< GlobalCompilationDatabase > getQueryDriverDatabase(llvm::ArrayRef< std::string > QueryDriverGlobs, std::unique_ptr< GlobalCompilationDatabase > Base)
Extracts system include search path from drivers matching QueryDriverGlobs and adds them to the compi...
void setCompileCommand(PathRef File, llvm::Optional< tooling::CompileCommand > CompilationCommand)
Sets or clears the compilation command for a particular file.
llvm::StringRef PathRef
A typedef to represent a ref to file path.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
virtual llvm::Optional< ProjectInfo > getProjectInfo(PathRef File) const
Finds the closest project to File.
Gets compile args from tooling::CompilationDatabases built for parent directories.
CommandChanged::Subscription watch(CommandChanged::Listener L) const
The callback is notified when files may have new compile commands.
CommandChanged OnCommandChanged
Wraps another compilation database, and supports overriding the commands using an in-memory mapping.