9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_GLOBALCOMPILATIONDATABASE_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_GLOBALCOMPILATIONDATABASE_H
16#include "clang/Tooling/ArgumentsAdjusters.h"
17#include "clang/Tooling/CompilationDatabase.h"
18#include "llvm/ADT/FunctionExtras.h"
19#include "llvm/ADT/StringMap.h"
40 virtual std::optional<tooling::CompileCommand>
72 DelegatingCDB(std::unique_ptr<GlobalCompilationDatabase> Base);
74 std::optional<tooling::CompileCommand>
85 std::unique_ptr<GlobalCompilationDatabase> BaseOwner;
86 CommandChanged::Subscription BaseChanged;
100 std::chrono::seconds(5);
104 std::chrono::seconds(30);
118 std::optional<tooling::CompileCommand>
133 mutable llvm::StringMap<DirectoryCache> DirCaches;
134 mutable std::mutex DirCachesMutex;
136 std::vector<DirectoryCache *>
137 getDirectoryCaches(llvm::ArrayRef<llvm::StringRef> Dirs)
const;
139 struct CDBLookupRequest {
142 bool ShouldBroadcast =
false;
145 std::chrono::steady_clock::time_point FreshTime;
146 std::chrono::steady_clock::time_point FreshTimeMissing;
148 struct CDBLookupResult {
149 std::shared_ptr<const tooling::CompilationDatabase> CDB;
152 std::optional<CDBLookupResult> lookupCDB(CDBLookupRequest Request)
const;
154 class BroadcastThread;
155 std::unique_ptr<BroadcastThread> Broadcaster;
158 void broadcastCDB(CDBLookupResult Res)
const;
168 tooling::CompileCommand &, llvm::StringRef)
const>;
179 StringRef
File)
const>;
185 std::vector<std::string> FallbackFlags = {},
188 std::optional<tooling::CompileCommand>
195 std::optional<tooling::CompileCommand> CompilationCommand);
198 mutable std::mutex Mutex;
199 llvm::StringMap<tooling::CompileCommand> Commands;
201 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.
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.
~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 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)