diff options
| author | Sam McCall <sam.mccall@gmail.com> | 2017-12-04 10:08:45 +0000 |
|---|---|---|
| committer | Sam McCall <sam.mccall@gmail.com> | 2017-12-04 10:08:45 +0000 |
| commit | aa49372548ff984ae9c48879a0d05833538a76b3 (patch) | |
| tree | 3a2dade0d624e66f39f689c8ab7bcc7e915c0078 /unittests | |
| parent | 68be76534dd276c6c849c367b2f7d2495cfdd540 (diff) | |
[clangd] GlobalCompilationDatabase interface changes
Summary:
- GlobalCompilationDatabase now returns a single command (that's all we use)
- fallback flags are now part of the GlobalCompilationDatabase.
There's a default implementation that they can optionally customize.
- this allows us to avoid invoking the fallback logic on two separate codepaths
- race on extra flags fixed by locking the mutex
- made GCD const-correct (DBGCD does have mutating methods)
Reviewers: hokein
Subscribers: klimek, cfe-commits, ilya-biryukov
Differential Revision: https://reviews.llvm.org/D40733
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@319647 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
| -rw-r--r-- | unittests/clangd/ClangdTests.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/unittests/clangd/ClangdTests.cpp b/unittests/clangd/ClangdTests.cpp index 73462e8d..c8d43972 100644 --- a/unittests/clangd/ClangdTests.cpp +++ b/unittests/clangd/ClangdTests.cpp @@ -212,21 +212,17 @@ public: ExtraClangFlags.push_back("-ffreestanding"); } - std::vector<tooling::CompileCommand> - getCompileCommands(PathRef File) override { + llvm::Optional<tooling::CompileCommand> + getCompileCommand(PathRef File) const override { if (ExtraClangFlags.empty()) - return {}; - - std::vector<std::string> CommandLine; - CommandLine.reserve(3 + ExtraClangFlags.size()); - CommandLine.insert(CommandLine.end(), {"clang", "-fsyntax-only"}); - CommandLine.insert(CommandLine.end(), ExtraClangFlags.begin(), - ExtraClangFlags.end()); - CommandLine.push_back(File.str()); + return llvm::None; + auto CommandLine = ExtraClangFlags; + CommandLine.insert(CommandLine.begin(), "clang"); + CommandLine.insert(CommandLine.end(), File.str()); return {tooling::CompileCommand(llvm::sys::path::parent_path(File), llvm::sys::path::filename(File), - CommandLine, "")}; + std::move(CommandLine), "")}; } std::vector<std::string> ExtraClangFlags; |
