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>
51 virtual tooling::CompileCommand getFallbackCommand(
PathRef File)
const;
57 return OnCommandChanged.observe(std::move(L));
70 llvm::Optional<Path> CompileCommandsDir);
76 llvm::Optional<tooling::CompileCommand>
81 llvm::Optional<ProjectInfo> getProjectInfo(
PathRef File)
const override;
87 std::unique_ptr<clang::tooling::CompilationDatabase> CDB =
nullptr;
88 bool SentBroadcast =
false;
90 CachedCDB &getCDBInDirLocked(
PathRef File)
const;
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);
131 std::vector<std::string> FallbackFlags = {},
132 tooling::ArgumentsAdjuster Adjuster =
nullptr);
134 llvm::Optional<tooling::CompileCommand>
136 tooling::CompileCommand getFallbackCommand(
PathRef File)
const override;
137 llvm::Optional<ProjectInfo> getProjectInfo(
PathRef File)
const override;
141 setCompileCommand(
PathRef File,
142 llvm::Optional<tooling::CompileCommand> CompilationCommand);
145 mutable std::mutex Mutex;
146 llvm::StringMap<tooling::CompileCommand>
Commands;
148 tooling::ArgumentsAdjuster ArgsAdjuster;
149 std::vector<std::string> FallbackFlags;
150 CommandChanged::Subscription BaseChanged;
156 #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.