9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_GLOBALCOMPILATIONDATABASE_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_GLOBALCOMPILATIONDATABASE_H
17#include "clang/Tooling/ArgumentsAdjusters.h"
18#include "clang/Tooling/CompilationDatabase.h"
19#include "llvm/ADT/FunctionExtras.h"
20#include "llvm/ADT/StringMap.h"
41 virtual std::optional<tooling::CompileCommand>
50 virtual std::unique_ptr<ProjectModules>
79 DelegatingCDB(std::unique_ptr<GlobalCompilationDatabase> Base);
81 std::optional<tooling::CompileCommand>
86 std::unique_ptr<ProjectModules>
95 std::unique_ptr<GlobalCompilationDatabase> BaseOwner;
96 CommandChanged::Subscription BaseChanged;
110 std::chrono::seconds(5);
114 std::chrono::seconds(30);
128 std::optional<tooling::CompileCommand>
135 std::unique_ptr<ProjectModules>
146 mutable llvm::StringMap<DirectoryCache> DirCaches;
147 mutable std::mutex DirCachesMutex;
149 std::vector<DirectoryCache *>
150 getDirectoryCaches(llvm::ArrayRef<llvm::StringRef> Dirs)
const;
152 struct CDBLookupRequest {
155 bool ShouldBroadcast =
false;
158 std::chrono::steady_clock::time_point FreshTime;
159 std::chrono::steady_clock::time_point FreshTimeMissing;
161 struct CDBLookupResult {
162 std::shared_ptr<const tooling::CompilationDatabase> CDB;
165 std::optional<CDBLookupResult> lookupCDB(CDBLookupRequest Request)
const;
167 class BroadcastThread;
168 std::unique_ptr<BroadcastThread> Broadcaster;
171 void broadcastCDB(CDBLookupResult Res)
const;
181 tooling::CompileCommand &, llvm::StringRef)
const>;
192 StringRef
File)
const>;
198 std::vector<std::string> FallbackFlags = {},
201 std::optional<tooling::CompileCommand>
208 std::optional<tooling::CompileCommand> CompilationCommand);
211 mutable std::mutex Mutex;
212 llvm::StringMap<tooling::CompileCommand> Commands;
214 std::vector<std::string> FallbackFlags;
A context is an immutable container for per-request data that must be propagated through layers that ...
A point in time we can wait for.
tooling::CompileCommand getFallbackCommand(PathRef File) const override
Makes a guess at how to build a file.
std::optional< tooling::CompileCommand > getCompileCommand(PathRef File) const override
If there are any known-good commands for building this file, returns one.
bool blockUntilIdle(Deadline D) const override
If the CDB does any asynchronous work, wait for it to complete.
std::optional< ProjectInfo > getProjectInfo(PathRef File) const override
Finds the closest project to File.
std::unique_ptr< ProjectModules > getProjectModules(PathRef File) const override
Get the modules in the closest project to File.
Gets compile args from tooling::CompilationDatabases built for parent directories.
bool blockUntilIdle(Deadline Timeout) const override
If the CDB does any asynchronous work, wait for it to complete.
std::unique_ptr< ProjectModules > getProjectModules(PathRef File) const override
Get the modules in the closest project to File.
~DirectoryBasedGlobalCompilationDatabase() override
std::optional< tooling::CompileCommand > getCompileCommand(PathRef File) const override
Scans File's parents looking for compilation databases.
std::optional< ProjectInfo > getProjectInfo(PathRef File) const override
Returns the path to first directory containing a compilation database in File's parents.
Subscription observe(Listener L)
std::function< void(const std::vector< std::string > &)> Listener
Provides compilation arguments used for parsing C and C++ files.
CommandChanged::Subscription watch(CommandChanged::Listener L) const
The callback is notified when files may have new compile commands.
virtual tooling::CompileCommand getFallbackCommand(PathRef File) const
Makes a guess at how to build a file.
virtual std::optional< ProjectInfo > getProjectInfo(PathRef File) const
Finds the closest project to File.
virtual std::unique_ptr< ProjectModules > getProjectModules(PathRef File) const
Get the modules in the closest project to File.
virtual bool blockUntilIdle(Deadline D) const
If the CDB does any asynchronous work, wait for it to complete.
virtual std::optional< tooling::CompileCommand > getCompileCommand(PathRef File) const =0
If there are any known-good commands for building this file, returns one.
CommandChanged OnCommandChanged
virtual ~GlobalCompilationDatabase()=default
Wraps another compilation database, and supports overriding the commands using an in-memory mapping.
tooling::CompileCommand getFallbackCommand(PathRef File) const override
Makes a guess at how to build a file.
void setCompileCommand(PathRef File, std::optional< tooling::CompileCommand > CompilationCommand)
Sets or clears the compilation command for a particular file.
std::optional< tooling::CompileCommand > getCompileCommand(PathRef File) const override
If there are any known-good commands for building this file, returns one.
llvm::unique_function< void(tooling::CompileCommand &, StringRef File) const > CommandMangler
Wrapper for vfs::FileSystem for use in multithreaded programs like clangd.
SystemIncludeExtractorFn getSystemIncludeExtractor(llvm::ArrayRef< std::string > QueryDriverGlobs)
llvm::unique_function< void(tooling::CompileCommand &, llvm::StringRef) const > SystemIncludeExtractorFn
Extracts system include search path from drivers matching QueryDriverGlobs and adds them to the compi...
llvm::StringRef PathRef
A typedef to represent a ref to file path.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
std::chrono::steady_clock::duration RevalidateAfter
std::chrono::steady_clock::duration RevalidateMissingAfter
std::function< Context(llvm::StringRef)> ContextProvider
std::optional< Path > CompileCommandsDir
Options(const ThreadsafeFS &TFS)