10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_GLOBALCOMPILATIONDATABASE_H 11 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_GLOBALCOMPILATIONDATABASE_H 15 #include "llvm/ADT/Optional.h" 16 #include "llvm/ADT/StringMap.h" 24 class CompilationDatabase;
25 struct CompileCommand;
45 virtual llvm::Optional<tooling::CompileCommand>
51 virtual tooling::CompileCommand getFallbackCommand(
PathRef File)
const;
57 return OnCommandChanged.observe(std::move(L));
75 llvm::Optional<tooling::CompileCommand>
79 tooling::CompilationDatabase *getCDBForFile(
PathRef File,
81 std::pair<tooling::CompilationDatabase *,
bool>
82 getCDBInDirLocked(
PathRef File)
const;
84 mutable std::mutex Mutex;
87 mutable llvm::StringMap<std::unique_ptr<clang::tooling::CompilationDatabase>>
102 std::vector<std::string> FallbackFlags = {},
103 llvm::Optional<std::string>
ResourceDir = llvm::None);
105 llvm::Optional<tooling::CompileCommand>
107 tooling::CompileCommand getFallbackCommand(
PathRef File)
const override;
111 setCompileCommand(
PathRef File,
112 llvm::Optional<tooling::CompileCommand> CompilationCommand);
115 mutable std::mutex Mutex;
116 llvm::StringMap<tooling::CompileCommand>
Commands;
119 std::vector<std::string> FallbackFlags;
120 CommandChanged::Subscription BaseChanged;
126 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_GLOBALCOMPILATIONDATABASE_H 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.
Provides compilation arguments used for parsing C and C++ files.
static llvm::cl::opt< Path > ResourceDir("resource-dir", llvm::cl::desc("Directory for system clang headers"), llvm::cl::init(""), llvm::cl::Hidden)
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++ -*-===//
Wraps another compilation database, and supports overriding the commands using an in-memory mapping...
static llvm::cl::opt< Path > CompileCommandsDir("compile-commands-dir", llvm::cl::desc("Specify a path to look for compile_commands.json. If path " "is invalid, clangd will look in the current directory and " "parent paths of each source file."))
CommandChanged OnCommandChanged