From aa49372548ff984ae9c48879a0d05833538a76b3 Mon Sep 17 00:00:00 2001 From: Sam McCall Date: Mon, 4 Dec 2017 10:08:45 +0000 Subject: [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 --- unittests/clangd/ClangdTests.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'unittests') 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 - getCompileCommands(PathRef File) override { + llvm::Optional + getCompileCommand(PathRef File) const override { if (ExtraClangFlags.empty()) - return {}; - - std::vector 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 ExtraClangFlags; -- cgit v1.2.3