9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_GLOBALCOMPILATIONDATABASE_H 10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_GLOBALCOMPILATIONDATABASE_H 14 #include "clang/Tooling/CompilationDatabase.h" 15 #include "llvm/ADT/Optional.h" 16 #include "llvm/ADT/StringMap.h" 39 virtual llvm::Optional<tooling::CompileCommand>
50 virtual tooling::CompileCommand getFallbackCommand(
PathRef File)
const;
56 return OnCommandChanged.observe(std::move(L));
69 llvm::Optional<Path> CompileCommandsDir);
75 llvm::Optional<tooling::CompileCommand>
80 llvm::Optional<ProjectInfo> getProjectInfo(
PathRef File)
const override;
86 std::unique_ptr<clang::tooling::CompilationDatabase> CDB =
nullptr;
87 bool SentBroadcast =
false;
89 CachedCDB &getCDBInDirLocked(
PathRef File)
const;
91 struct CDBLookupRequest {
94 bool ShouldBroadcast =
false;
96 struct CDBLookupResult {
97 tooling::CompilationDatabase *CDB =
nullptr;
100 llvm::Optional<CDBLookupResult> lookupCDB(CDBLookupRequest Request)
const;
103 void broadcastCDB(CDBLookupResult Res)
const;
105 mutable std::mutex Mutex;
107 mutable llvm::StringMap<CachedCDB> CompilationDatabases;
111 llvm::Optional<Path> CompileCommandsDir;
117 std::unique_ptr<GlobalCompilationDatabase>
119 std::unique_ptr<GlobalCompilationDatabase>
Base);
128 std::vector<std::string> FallbackFlags = {},
129 llvm::Optional<std::string> ResourceDir =
llvm::None);
131 llvm::Optional<tooling::CompileCommand>
133 tooling::CompileCommand getFallbackCommand(
PathRef File)
const override;
134 llvm::Optional<ProjectInfo> getProjectInfo(
PathRef File)
const override;
138 setCompileCommand(
PathRef File,
139 llvm::Optional<tooling::CompileCommand> CompilationCommand);
142 mutable std::mutex Mutex;
143 llvm::StringMap<tooling::CompileCommand>
Commands;
145 std::string ResourceDir;
146 std::vector<std::string> FallbackFlags;
147 CommandChanged::Subscription BaseChanged;
153 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_GLOBALCOMPILATIONDATABASE_H 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...
std::function< void(const std::vector< std::string > &)> Listener
static cl::list< std::string > Commands("c", cl::desc("Specify command to run"), cl::value_desc("command"), cl::cat(ClangQueryCategory))
llvm::StringRef PathRef
A typedef to represent a ref to file path.
Documents should not be synced at all.
Provides compilation arguments used for parsing C and C++ files.
std::string Path
A typedef to represent a file path.
CommandChanged::Subscription watch(CommandChanged::Listener L) const
The callback is notified when files may have new compile commands.
Gets compile args from tooling::CompilationDatabases built for parent directories.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
std::unique_ptr< GlobalCompilationDatabase > Base
Wraps another compilation database, and supports overriding the commands using an in-memory mapping...
CommandChanged OnCommandChanged
virtual llvm::Optional< ProjectInfo > getProjectInfo(PathRef File) const
Finds the closest project to File.