2018-08-15 00:03:32 +08:00
|
|
|
//===--- GlobalCompilationDatabase.cpp ---------------------------*- C++-*-===//
|
2017-05-16 17:38:59 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2017-05-16 17:38:59 +08:00
|
|
|
//
|
2018-08-15 00:03:32 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2017-05-16 17:38:59 +08:00
|
|
|
|
|
|
|
#include "GlobalCompilationDatabase.h"
|
2017-10-02 23:13:20 +08:00
|
|
|
#include "Logger.h"
|
2019-01-22 17:10:20 +08:00
|
|
|
#include "clang/Frontend/CompilerInvocation.h"
|
|
|
|
#include "clang/Tooling/ArgumentsAdjusters.h"
|
2017-05-16 17:38:59 +08:00
|
|
|
#include "clang/Tooling/CompilationDatabase.h"
|
2019-01-22 17:10:20 +08:00
|
|
|
#include "llvm/ADT/Optional.h"
|
2017-05-16 17:38:59 +08:00
|
|
|
#include "llvm/Support/FileSystem.h"
|
|
|
|
#include "llvm/Support/Path.h"
|
|
|
|
|
2017-07-06 16:44:54 +08:00
|
|
|
namespace clang {
|
|
|
|
namespace clangd {
|
2019-01-22 17:10:20 +08:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
void adjustArguments(tooling::CompileCommand &Cmd,
|
|
|
|
llvm::StringRef ResourceDir) {
|
|
|
|
// Strip plugin related command line arguments. Clangd does
|
|
|
|
// not support plugins currently. Therefore it breaks if
|
|
|
|
// compiler tries to load plugins.
|
|
|
|
Cmd.CommandLine =
|
|
|
|
tooling::getStripPluginsAdjuster()(Cmd.CommandLine, Cmd.Filename);
|
|
|
|
// Inject the resource dir.
|
|
|
|
// FIXME: Don't overwrite it if it's already there.
|
|
|
|
if (!ResourceDir.empty())
|
|
|
|
Cmd.CommandLine.push_back(("-resource-dir=" + ResourceDir).str());
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string getStandardResourceDir() {
|
|
|
|
static int Dummy; // Just an address in this process.
|
|
|
|
return CompilerInvocation::GetResourcesPath("clangd", (void *)&Dummy);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
2017-07-06 16:44:54 +08:00
|
|
|
|
2019-01-07 20:35:02 +08:00
|
|
|
static std::string getFallbackClangPath() {
|
|
|
|
static int Dummy;
|
|
|
|
std::string ClangdExecutable =
|
|
|
|
llvm::sys::fs::getMainExecutable("clangd", (void *)&Dummy);
|
|
|
|
SmallString<128> ClangPath;
|
|
|
|
ClangPath = llvm::sys::path::parent_path(ClangdExecutable);
|
|
|
|
llvm::sys::path::append(ClangPath, "clang");
|
|
|
|
return ClangPath.str();
|
|
|
|
}
|
|
|
|
|
2017-12-04 18:08:45 +08:00
|
|
|
tooling::CompileCommand
|
|
|
|
GlobalCompilationDatabase::getFallbackCommand(PathRef File) const {
|
2019-01-07 20:35:02 +08:00
|
|
|
std::vector<std::string> Argv = {getFallbackClangPath()};
|
2018-04-20 19:35:17 +08:00
|
|
|
// Clang treats .h files as C by default, resulting in unhelpful diagnostics.
|
|
|
|
// Parsing as Objective C++ is friendly to more cases.
|
2019-01-07 23:45:19 +08:00
|
|
|
if (llvm::sys::path::extension(File) == ".h")
|
2018-04-20 19:35:17 +08:00
|
|
|
Argv.push_back("-xobjective-c++-header");
|
|
|
|
Argv.push_back(File);
|
2019-01-07 23:45:19 +08:00
|
|
|
return tooling::CompileCommand(llvm::sys::path::parent_path(File),
|
|
|
|
llvm::sys::path::filename(File),
|
|
|
|
std::move(Argv),
|
2017-07-06 16:44:54 +08:00
|
|
|
/*Output=*/"");
|
|
|
|
}
|
2017-05-16 17:38:59 +08:00
|
|
|
|
2017-09-20 15:24:15 +08:00
|
|
|
DirectoryBasedGlobalCompilationDatabase::
|
2019-01-07 23:45:19 +08:00
|
|
|
DirectoryBasedGlobalCompilationDatabase(
|
|
|
|
llvm::Optional<Path> CompileCommandsDir)
|
2017-12-13 20:51:22 +08:00
|
|
|
: CompileCommandsDir(std::move(CompileCommandsDir)) {}
|
2017-09-20 15:24:15 +08:00
|
|
|
|
2018-04-20 19:35:17 +08:00
|
|
|
DirectoryBasedGlobalCompilationDatabase::
|
|
|
|
~DirectoryBasedGlobalCompilationDatabase() = default;
|
|
|
|
|
2019-01-07 23:45:19 +08:00
|
|
|
llvm::Optional<tooling::CompileCommand>
|
[clangd] Auto-index watches global CDB for changes.
Summary:
Instead of receiving compilation commands, auto-index is triggered by just
filenames to reindex, and gets commands from the global comp DB internally.
This has advantages:
- more of the work can be done asynchronously (fetching compilation commands
upfront can be slow for large CDBs)
- we get access to the CDB which can be used to retrieve interpolated commands
for headers (useful in some cases where the original TU goes away)
- fits nicely with the filename-only change observation from r347297
The interface to GlobalCompilationDatabase gets extended: when retrieving a
compile command, the GCDB can optionally report the project the file belongs to.
This naturally fits together with getCompileCommand: it's hard to implement one
without the other. But because most callers don't care, I've ended up with an
awkward optional-out-param-in-virtual method pattern - maybe there's a better
one.
This is the main missing integration point between ClangdServer and
BackgroundIndex, after this we should be able to add an auto-index flag.
Reviewers: ioeric, kadircet
Subscribers: MaskRay, jkorous, arphaman, cfe-commits, ilya-biryukov
Differential Revision: https://reviews.llvm.org/D54865
llvm-svn: 347538
2018-11-26 17:51:50 +08:00
|
|
|
DirectoryBasedGlobalCompilationDatabase::getCompileCommand(
|
|
|
|
PathRef File, ProjectInfo *Project) const {
|
|
|
|
if (auto CDB = getCDBForFile(File, Project)) {
|
2017-12-04 18:08:45 +08:00
|
|
|
auto Candidates = CDB->getCompileCommands(File);
|
[clangd] Auto-index watches global CDB for changes.
Summary:
Instead of receiving compilation commands, auto-index is triggered by just
filenames to reindex, and gets commands from the global comp DB internally.
This has advantages:
- more of the work can be done asynchronously (fetching compilation commands
upfront can be slow for large CDBs)
- we get access to the CDB which can be used to retrieve interpolated commands
for headers (useful in some cases where the original TU goes away)
- fits nicely with the filename-only change observation from r347297
The interface to GlobalCompilationDatabase gets extended: when retrieving a
compile command, the GCDB can optionally report the project the file belongs to.
This naturally fits together with getCompileCommand: it's hard to implement one
without the other. But because most callers don't care, I've ended up with an
awkward optional-out-param-in-virtual method pattern - maybe there's a better
one.
This is the main missing integration point between ClangdServer and
BackgroundIndex, after this we should be able to add an auto-index flag.
Reviewers: ioeric, kadircet
Subscribers: MaskRay, jkorous, arphaman, cfe-commits, ilya-biryukov
Differential Revision: https://reviews.llvm.org/D54865
llvm-svn: 347538
2018-11-26 17:51:50 +08:00
|
|
|
if (!Candidates.empty()) {
|
2017-12-04 18:08:45 +08:00
|
|
|
return std::move(Candidates.front());
|
[clangd] Auto-index watches global CDB for changes.
Summary:
Instead of receiving compilation commands, auto-index is triggered by just
filenames to reindex, and gets commands from the global comp DB internally.
This has advantages:
- more of the work can be done asynchronously (fetching compilation commands
upfront can be slow for large CDBs)
- we get access to the CDB which can be used to retrieve interpolated commands
for headers (useful in some cases where the original TU goes away)
- fits nicely with the filename-only change observation from r347297
The interface to GlobalCompilationDatabase gets extended: when retrieving a
compile command, the GCDB can optionally report the project the file belongs to.
This naturally fits together with getCompileCommand: it's hard to implement one
without the other. But because most callers don't care, I've ended up with an
awkward optional-out-param-in-virtual method pattern - maybe there's a better
one.
This is the main missing integration point between ClangdServer and
BackgroundIndex, after this we should be able to add an auto-index flag.
Reviewers: ioeric, kadircet
Subscribers: MaskRay, jkorous, arphaman, cfe-commits, ilya-biryukov
Differential Revision: https://reviews.llvm.org/D54865
llvm-svn: 347538
2018-11-26 17:51:50 +08:00
|
|
|
}
|
2017-12-22 17:47:34 +08:00
|
|
|
} else {
|
[clangd] Upgrade logging facilities with levels and formatv.
Summary:
log() is split into four functions:
- elog()/log()/vlog() have different severity levels, allowing filtering
- dlog() is a lazy macro which uses LLVM_DEBUG - it logs to the logger, but
conditionally based on -debug-only flag and is omitted in release builds
All logging functions use formatv-style format strings now, e.g:
log("Could not resolve URI {0}: {1}", URI, Result.takeError());
Existing log sites have been split between elog/log/vlog by best guess.
This includes a workaround for passing Error to formatv that can be
simplified when D49170 or similar lands.
Subscribers: ilya-biryukov, javed.absar, ioeric, MaskRay, jkorous, cfe-commits
Differential Revision: https://reviews.llvm.org/D49008
llvm-svn: 336785
2018-07-11 18:35:11 +08:00
|
|
|
log("Failed to find compilation database for {0}", File);
|
2017-07-06 16:44:54 +08:00
|
|
|
}
|
2018-10-20 23:30:37 +08:00
|
|
|
return None;
|
2017-12-04 18:08:45 +08:00
|
|
|
}
|
2017-07-06 16:44:54 +08:00
|
|
|
|
2018-11-20 18:56:03 +08:00
|
|
|
std::pair<tooling::CompilationDatabase *, /*Cached*/ bool>
|
2017-12-22 17:47:34 +08:00
|
|
|
DirectoryBasedGlobalCompilationDatabase::getCDBInDirLocked(PathRef Dir) const {
|
|
|
|
// FIXME(ibiryukov): Invalidate cached compilation databases on changes
|
|
|
|
auto CachedIt = CompilationDatabases.find(Dir);
|
2017-10-02 23:13:20 +08:00
|
|
|
if (CachedIt != CompilationDatabases.end())
|
2018-11-20 18:56:03 +08:00
|
|
|
return {CachedIt->second.get(), true};
|
2017-10-02 23:13:20 +08:00
|
|
|
std::string Error = "";
|
2017-12-22 17:47:34 +08:00
|
|
|
auto CDB = tooling::CompilationDatabase::loadFromDirectory(Dir, Error);
|
|
|
|
auto Result = CDB.get();
|
|
|
|
CompilationDatabases.insert(std::make_pair(Dir, std::move(CDB)));
|
2018-11-20 18:56:03 +08:00
|
|
|
return {Result, false};
|
2017-10-02 23:13:20 +08:00
|
|
|
}
|
2017-09-20 15:24:15 +08:00
|
|
|
|
2017-10-02 23:13:20 +08:00
|
|
|
tooling::CompilationDatabase *
|
[clangd] Auto-index watches global CDB for changes.
Summary:
Instead of receiving compilation commands, auto-index is triggered by just
filenames to reindex, and gets commands from the global comp DB internally.
This has advantages:
- more of the work can be done asynchronously (fetching compilation commands
upfront can be slow for large CDBs)
- we get access to the CDB which can be used to retrieve interpolated commands
for headers (useful in some cases where the original TU goes away)
- fits nicely with the filename-only change observation from r347297
The interface to GlobalCompilationDatabase gets extended: when retrieving a
compile command, the GCDB can optionally report the project the file belongs to.
This naturally fits together with getCompileCommand: it's hard to implement one
without the other. But because most callers don't care, I've ended up with an
awkward optional-out-param-in-virtual method pattern - maybe there's a better
one.
This is the main missing integration point between ClangdServer and
BackgroundIndex, after this we should be able to add an auto-index flag.
Reviewers: ioeric, kadircet
Subscribers: MaskRay, jkorous, arphaman, cfe-commits, ilya-biryukov
Differential Revision: https://reviews.llvm.org/D54865
llvm-svn: 347538
2018-11-26 17:51:50 +08:00
|
|
|
DirectoryBasedGlobalCompilationDatabase::getCDBForFile(
|
|
|
|
PathRef File, ProjectInfo *Project) const {
|
2019-01-07 23:45:19 +08:00
|
|
|
namespace path = llvm::sys::path;
|
2017-12-22 17:47:34 +08:00
|
|
|
assert((path::is_absolute(File, path::Style::posix) ||
|
|
|
|
path::is_absolute(File, path::Style::windows)) &&
|
|
|
|
"path must be absolute");
|
2017-10-02 23:13:20 +08:00
|
|
|
|
2018-11-20 18:56:03 +08:00
|
|
|
tooling::CompilationDatabase *CDB = nullptr;
|
|
|
|
bool Cached = false;
|
2017-12-22 17:47:34 +08:00
|
|
|
std::lock_guard<std::mutex> Lock(Mutex);
|
2018-11-20 18:56:03 +08:00
|
|
|
if (CompileCommandsDir) {
|
|
|
|
std::tie(CDB, Cached) = getCDBInDirLocked(*CompileCommandsDir);
|
[clangd] Auto-index watches global CDB for changes.
Summary:
Instead of receiving compilation commands, auto-index is triggered by just
filenames to reindex, and gets commands from the global comp DB internally.
This has advantages:
- more of the work can be done asynchronously (fetching compilation commands
upfront can be slow for large CDBs)
- we get access to the CDB which can be used to retrieve interpolated commands
for headers (useful in some cases where the original TU goes away)
- fits nicely with the filename-only change observation from r347297
The interface to GlobalCompilationDatabase gets extended: when retrieving a
compile command, the GCDB can optionally report the project the file belongs to.
This naturally fits together with getCompileCommand: it's hard to implement one
without the other. But because most callers don't care, I've ended up with an
awkward optional-out-param-in-virtual method pattern - maybe there's a better
one.
This is the main missing integration point between ClangdServer and
BackgroundIndex, after this we should be able to add an auto-index flag.
Reviewers: ioeric, kadircet
Subscribers: MaskRay, jkorous, arphaman, cfe-commits, ilya-biryukov
Differential Revision: https://reviews.llvm.org/D54865
llvm-svn: 347538
2018-11-26 17:51:50 +08:00
|
|
|
if (Project && CDB)
|
|
|
|
Project->SourceRoot = *CompileCommandsDir;
|
2018-11-20 18:56:03 +08:00
|
|
|
} else {
|
|
|
|
for (auto Path = path::parent_path(File); !CDB && !Path.empty();
|
|
|
|
Path = path::parent_path(Path)) {
|
|
|
|
std::tie(CDB, Cached) = getCDBInDirLocked(Path);
|
[clangd] Auto-index watches global CDB for changes.
Summary:
Instead of receiving compilation commands, auto-index is triggered by just
filenames to reindex, and gets commands from the global comp DB internally.
This has advantages:
- more of the work can be done asynchronously (fetching compilation commands
upfront can be slow for large CDBs)
- we get access to the CDB which can be used to retrieve interpolated commands
for headers (useful in some cases where the original TU goes away)
- fits nicely with the filename-only change observation from r347297
The interface to GlobalCompilationDatabase gets extended: when retrieving a
compile command, the GCDB can optionally report the project the file belongs to.
This naturally fits together with getCompileCommand: it's hard to implement one
without the other. But because most callers don't care, I've ended up with an
awkward optional-out-param-in-virtual method pattern - maybe there's a better
one.
This is the main missing integration point between ClangdServer and
BackgroundIndex, after this we should be able to add an auto-index flag.
Reviewers: ioeric, kadircet
Subscribers: MaskRay, jkorous, arphaman, cfe-commits, ilya-biryukov
Differential Revision: https://reviews.llvm.org/D54865
llvm-svn: 347538
2018-11-26 17:51:50 +08:00
|
|
|
if (Project && CDB)
|
|
|
|
Project->SourceRoot = Path;
|
2018-11-20 18:56:03 +08:00
|
|
|
}
|
|
|
|
}
|
[clangd] Enable auto-index behind a flag.
Summary:
Ownership and configuration:
The auto-index (background index) is maintained by ClangdServer, like Dynamic.
(This means ClangdServer will be able to enqueue preamble indexing in future).
For now it's enabled by a simple boolean flag in ClangdServer::Options, but
we probably want to eventually allow injecting the storage strategy.
New 'sync' command:
In order to meaningfully test the integration (not just unit-test components)
we need a way for tests to ensure the asynchronous index reads/writes occur
before a certain point.
Because these tests and assertions are few, I think exposing an explicit "sync"
command for use in tests is simpler than allowing threading to be completely
disabled in the background index (as we do for TUScheduler).
Bugs:
I fixed a couple of trivial bugs I found while testing, but there's one I can't.
JSONCompilationDatabase::getAllFiles() may return relative paths, and currently
we trigger an assertion that assumes they are absolute.
There's no efficient way to resolve them (you have to retrieve the corresponding
command and then resolve against its directory property). In general I think
this behavior is broken and we should fix it in JSONCompilationDatabase and
require CompilationDatabase::getAllFiles() to be absolute.
Reviewers: kadircet
Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits
Differential Revision: https://reviews.llvm.org/D54894
llvm-svn: 347567
2018-11-27 00:00:11 +08:00
|
|
|
// FIXME: getAllFiles() may return relative paths, we need absolute paths.
|
|
|
|
// Hopefully the fix is to change JSONCompilationDatabase and the interface.
|
2018-11-20 18:56:03 +08:00
|
|
|
if (CDB && !Cached)
|
|
|
|
OnCommandChanged.broadcast(CDB->getAllFiles());
|
|
|
|
return CDB;
|
|
|
|
}
|
|
|
|
|
|
|
|
OverlayCDB::OverlayCDB(const GlobalCompilationDatabase *Base,
|
2019-01-22 17:10:20 +08:00
|
|
|
std::vector<std::string> FallbackFlags,
|
|
|
|
llvm::Optional<std::string> ResourceDir)
|
|
|
|
: Base(Base), ResourceDir(ResourceDir ? std::move(*ResourceDir)
|
|
|
|
: getStandardResourceDir()),
|
|
|
|
FallbackFlags(std::move(FallbackFlags)) {
|
2018-11-20 18:56:03 +08:00
|
|
|
if (Base)
|
|
|
|
BaseChanged = Base->watch([this](const std::vector<std::string> Changes) {
|
|
|
|
OnCommandChanged.broadcast(Changes);
|
|
|
|
});
|
2017-05-16 17:38:59 +08:00
|
|
|
}
|
2017-07-06 16:44:54 +08:00
|
|
|
|
2019-01-07 23:45:19 +08:00
|
|
|
llvm::Optional<tooling::CompileCommand>
|
[clangd] Auto-index watches global CDB for changes.
Summary:
Instead of receiving compilation commands, auto-index is triggered by just
filenames to reindex, and gets commands from the global comp DB internally.
This has advantages:
- more of the work can be done asynchronously (fetching compilation commands
upfront can be slow for large CDBs)
- we get access to the CDB which can be used to retrieve interpolated commands
for headers (useful in some cases where the original TU goes away)
- fits nicely with the filename-only change observation from r347297
The interface to GlobalCompilationDatabase gets extended: when retrieving a
compile command, the GCDB can optionally report the project the file belongs to.
This naturally fits together with getCompileCommand: it's hard to implement one
without the other. But because most callers don't care, I've ended up with an
awkward optional-out-param-in-virtual method pattern - maybe there's a better
one.
This is the main missing integration point between ClangdServer and
BackgroundIndex, after this we should be able to add an auto-index flag.
Reviewers: ioeric, kadircet
Subscribers: MaskRay, jkorous, arphaman, cfe-commits, ilya-biryukov
Differential Revision: https://reviews.llvm.org/D54865
llvm-svn: 347538
2018-11-26 17:51:50 +08:00
|
|
|
OverlayCDB::getCompileCommand(PathRef File, ProjectInfo *Project) const {
|
2019-01-22 17:10:20 +08:00
|
|
|
llvm::Optional<tooling::CompileCommand> Cmd;
|
2018-11-02 21:09:36 +08:00
|
|
|
{
|
|
|
|
std::lock_guard<std::mutex> Lock(Mutex);
|
|
|
|
auto It = Commands.find(File);
|
[clangd] Auto-index watches global CDB for changes.
Summary:
Instead of receiving compilation commands, auto-index is triggered by just
filenames to reindex, and gets commands from the global comp DB internally.
This has advantages:
- more of the work can be done asynchronously (fetching compilation commands
upfront can be slow for large CDBs)
- we get access to the CDB which can be used to retrieve interpolated commands
for headers (useful in some cases where the original TU goes away)
- fits nicely with the filename-only change observation from r347297
The interface to GlobalCompilationDatabase gets extended: when retrieving a
compile command, the GCDB can optionally report the project the file belongs to.
This naturally fits together with getCompileCommand: it's hard to implement one
without the other. But because most callers don't care, I've ended up with an
awkward optional-out-param-in-virtual method pattern - maybe there's a better
one.
This is the main missing integration point between ClangdServer and
BackgroundIndex, after this we should be able to add an auto-index flag.
Reviewers: ioeric, kadircet
Subscribers: MaskRay, jkorous, arphaman, cfe-commits, ilya-biryukov
Differential Revision: https://reviews.llvm.org/D54865
llvm-svn: 347538
2018-11-26 17:51:50 +08:00
|
|
|
if (It != Commands.end()) {
|
|
|
|
if (Project)
|
|
|
|
Project->SourceRoot = "";
|
2019-01-22 17:10:20 +08:00
|
|
|
Cmd = It->second;
|
[clangd] Auto-index watches global CDB for changes.
Summary:
Instead of receiving compilation commands, auto-index is triggered by just
filenames to reindex, and gets commands from the global comp DB internally.
This has advantages:
- more of the work can be done asynchronously (fetching compilation commands
upfront can be slow for large CDBs)
- we get access to the CDB which can be used to retrieve interpolated commands
for headers (useful in some cases where the original TU goes away)
- fits nicely with the filename-only change observation from r347297
The interface to GlobalCompilationDatabase gets extended: when retrieving a
compile command, the GCDB can optionally report the project the file belongs to.
This naturally fits together with getCompileCommand: it's hard to implement one
without the other. But because most callers don't care, I've ended up with an
awkward optional-out-param-in-virtual method pattern - maybe there's a better
one.
This is the main missing integration point between ClangdServer and
BackgroundIndex, after this we should be able to add an auto-index flag.
Reviewers: ioeric, kadircet
Subscribers: MaskRay, jkorous, arphaman, cfe-commits, ilya-biryukov
Differential Revision: https://reviews.llvm.org/D54865
llvm-svn: 347538
2018-11-26 17:51:50 +08:00
|
|
|
}
|
2018-11-02 21:09:36 +08:00
|
|
|
}
|
2019-01-22 17:10:20 +08:00
|
|
|
if (!Cmd && Base)
|
|
|
|
Cmd = Base->getCompileCommand(File, Project);
|
|
|
|
if (!Cmd)
|
|
|
|
return llvm::None;
|
|
|
|
adjustArguments(*Cmd, ResourceDir);
|
|
|
|
return Cmd;
|
2018-11-02 21:09:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
tooling::CompileCommand OverlayCDB::getFallbackCommand(PathRef File) const {
|
|
|
|
auto Cmd = Base ? Base->getFallbackCommand(File)
|
|
|
|
: GlobalCompilationDatabase::getFallbackCommand(File);
|
2018-08-02 01:39:29 +08:00
|
|
|
std::lock_guard<std::mutex> Lock(Mutex);
|
2018-11-02 21:09:36 +08:00
|
|
|
Cmd.CommandLine.insert(Cmd.CommandLine.end(), FallbackFlags.begin(),
|
|
|
|
FallbackFlags.end());
|
|
|
|
return Cmd;
|
2018-08-02 01:39:29 +08:00
|
|
|
}
|
|
|
|
|
2018-11-02 21:09:36 +08:00
|
|
|
void OverlayCDB::setCompileCommand(
|
|
|
|
PathRef File, llvm::Optional<tooling::CompileCommand> Cmd) {
|
2018-11-20 18:56:03 +08:00
|
|
|
{
|
|
|
|
std::unique_lock<std::mutex> Lock(Mutex);
|
|
|
|
if (Cmd)
|
|
|
|
Commands[File] = std::move(*Cmd);
|
|
|
|
else
|
|
|
|
Commands.erase(File);
|
|
|
|
}
|
|
|
|
OnCommandChanged.broadcast({File});
|
2018-08-02 01:39:29 +08:00
|
|
|
}
|
|
|
|
|
2017-07-06 16:44:54 +08:00
|
|
|
} // namespace clangd
|
|
|
|
} // namespace clang
|