2018-04-20 19:35:17 +08:00
|
|
|
//===-- GlobalCompilationDatabaseTests.cpp ----------------------*- C++ -*-===//
|
|
|
|
//
|
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
|
2018-04-20 19:35:17 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "GlobalCompilationDatabase.h"
|
|
|
|
|
2019-07-11 17:54:31 +08:00
|
|
|
#include "Path.h"
|
2018-04-20 19:35:17 +08:00
|
|
|
#include "TestFS.h"
|
2019-07-11 17:54:31 +08:00
|
|
|
#include "llvm/ADT/Optional.h"
|
|
|
|
#include "llvm/ADT/SmallString.h"
|
2018-04-20 19:35:17 +08:00
|
|
|
#include "llvm/ADT/StringExtras.h"
|
2019-07-11 17:54:31 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
#include "llvm/Support/FileSystem.h"
|
|
|
|
#include "llvm/Support/FormatVariadic.h"
|
|
|
|
#include "llvm/Support/MemoryBuffer.h"
|
|
|
|
#include "llvm/Support/Path.h"
|
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2018-04-20 19:35:17 +08:00
|
|
|
#include "gmock/gmock.h"
|
|
|
|
#include "gtest/gtest.h"
|
2019-07-11 17:54:31 +08:00
|
|
|
#include <fstream>
|
|
|
|
#include <string>
|
2018-04-20 19:35:17 +08:00
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace clangd {
|
|
|
|
namespace {
|
[clangd] Adjust compile commands to be applicable for tooling
Summary:
As can be seen in https://github.com/llvm-mirror/clang/blob/master/lib/Tooling/Tooling.cpp#L385
clang tool invocations adjust commands normally like this. In clangd we have
different code paths for invoking a frontend action(preamble builds, ast builds,
background index, clangd-indexer) they all work on the same GlobalCompilationDatabase
abstraction, but later on are subject to different modifications.
This patch makes sure all of the clangd actions make use of the same compile
commands before invocation.
Enables background-index to work on chromium codebase(since they had dependency
file output in their compile commands).
Reviewers: gribozavr, hokein
Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jdoerfert, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D59086
llvm-svn: 355669
2019-03-08 16:38:25 +08:00
|
|
|
using ::testing::AllOf;
|
|
|
|
using ::testing::Contains;
|
2018-04-20 19:35:17 +08:00
|
|
|
using ::testing::ElementsAre;
|
2019-01-07 20:35:02 +08:00
|
|
|
using ::testing::EndsWith;
|
2019-07-11 17:54:31 +08:00
|
|
|
using ::testing::IsEmpty;
|
[clangd] Adjust compile commands to be applicable for tooling
Summary:
As can be seen in https://github.com/llvm-mirror/clang/blob/master/lib/Tooling/Tooling.cpp#L385
clang tool invocations adjust commands normally like this. In clangd we have
different code paths for invoking a frontend action(preamble builds, ast builds,
background index, clangd-indexer) they all work on the same GlobalCompilationDatabase
abstraction, but later on are subject to different modifications.
This patch makes sure all of the clangd actions make use of the same compile
commands before invocation.
Enables background-index to work on chromium codebase(since they had dependency
file output in their compile commands).
Reviewers: gribozavr, hokein
Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jdoerfert, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D59086
llvm-svn: 355669
2019-03-08 16:38:25 +08:00
|
|
|
using ::testing::Not;
|
2019-06-04 21:38:36 +08:00
|
|
|
using ::testing::StartsWith;
|
2019-07-11 17:54:31 +08:00
|
|
|
using ::testing::UnorderedElementsAre;
|
2018-04-20 19:35:17 +08:00
|
|
|
|
|
|
|
TEST(GlobalCompilationDatabaseTest, FallbackCommand) {
|
2018-10-20 23:30:37 +08:00
|
|
|
DirectoryBasedGlobalCompilationDatabase DB(None);
|
2018-04-20 19:35:17 +08:00
|
|
|
auto Cmd = DB.getFallbackCommand(testPath("foo/bar.cc"));
|
|
|
|
EXPECT_EQ(Cmd.Directory, testPath("foo"));
|
[clangd] Adjust compile commands to be applicable for tooling
Summary:
As can be seen in https://github.com/llvm-mirror/clang/blob/master/lib/Tooling/Tooling.cpp#L385
clang tool invocations adjust commands normally like this. In clangd we have
different code paths for invoking a frontend action(preamble builds, ast builds,
background index, clangd-indexer) they all work on the same GlobalCompilationDatabase
abstraction, but later on are subject to different modifications.
This patch makes sure all of the clangd actions make use of the same compile
commands before invocation.
Enables background-index to work on chromium codebase(since they had dependency
file output in their compile commands).
Reviewers: gribozavr, hokein
Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jdoerfert, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D59086
llvm-svn: 355669
2019-03-08 16:38:25 +08:00
|
|
|
EXPECT_THAT(Cmd.CommandLine,
|
|
|
|
ElementsAre(EndsWith("clang"), testPath("foo/bar.cc")));
|
2018-04-20 19:35:17 +08:00
|
|
|
EXPECT_EQ(Cmd.Output, "");
|
|
|
|
|
|
|
|
// .h files have unknown language, so they are parsed liberally as obj-c++.
|
|
|
|
Cmd = DB.getFallbackCommand(testPath("foo/bar.h"));
|
2019-01-07 20:35:02 +08:00
|
|
|
EXPECT_THAT(Cmd.CommandLine,
|
|
|
|
ElementsAre(EndsWith("clang"), "-xobjective-c++-header",
|
|
|
|
testPath("foo/bar.h")));
|
2019-06-18 19:54:17 +08:00
|
|
|
Cmd = DB.getFallbackCommand(testPath("foo/bar"));
|
|
|
|
EXPECT_THAT(Cmd.CommandLine,
|
|
|
|
ElementsAre(EndsWith("clang"), "-xobjective-c++-header",
|
|
|
|
testPath("foo/bar")));
|
2018-04-20 19:35:17 +08:00
|
|
|
}
|
|
|
|
|
2019-01-07 23:45:19 +08:00
|
|
|
static tooling::CompileCommand cmd(llvm::StringRef File, llvm::StringRef Arg) {
|
2018-11-02 21:09:36 +08:00
|
|
|
return tooling::CompileCommand(testRoot(), File, {"clang", Arg, File}, "");
|
|
|
|
}
|
|
|
|
|
|
|
|
class OverlayCDBTest : public ::testing::Test {
|
|
|
|
class BaseCDB : public GlobalCompilationDatabase {
|
|
|
|
public:
|
2019-01-07 23:45:19 +08:00
|
|
|
llvm::Optional<tooling::CompileCommand>
|
2019-07-11 17:54:31 +08:00
|
|
|
getCompileCommand(llvm::StringRef File) const override {
|
|
|
|
if (File == testPath("foo.cc"))
|
2018-11-02 21:09:36 +08:00
|
|
|
return cmd(File, "-DA=1");
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
2019-01-07 23:45:19 +08:00
|
|
|
tooling::CompileCommand
|
|
|
|
getFallbackCommand(llvm::StringRef File) const override {
|
2018-11-02 21:09:36 +08:00
|
|
|
return cmd(File, "-DA=2");
|
|
|
|
}
|
2019-07-11 17:54:31 +08:00
|
|
|
|
|
|
|
llvm::Optional<ProjectInfo> getProjectInfo(PathRef File) const override {
|
|
|
|
return ProjectInfo{testRoot()};
|
|
|
|
}
|
2018-11-02 21:09:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
protected:
|
|
|
|
OverlayCDBTest() : Base(llvm::make_unique<BaseCDB>()) {}
|
|
|
|
std::unique_ptr<GlobalCompilationDatabase> Base;
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_F(OverlayCDBTest, GetCompileCommand) {
|
2019-01-22 17:10:20 +08:00
|
|
|
OverlayCDB CDB(Base.get(), {}, std::string(""));
|
[clangd] Adjust compile commands to be applicable for tooling
Summary:
As can be seen in https://github.com/llvm-mirror/clang/blob/master/lib/Tooling/Tooling.cpp#L385
clang tool invocations adjust commands normally like this. In clangd we have
different code paths for invoking a frontend action(preamble builds, ast builds,
background index, clangd-indexer) they all work on the same GlobalCompilationDatabase
abstraction, but later on are subject to different modifications.
This patch makes sure all of the clangd actions make use of the same compile
commands before invocation.
Enables background-index to work on chromium codebase(since they had dependency
file output in their compile commands).
Reviewers: gribozavr, hokein
Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jdoerfert, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D59086
llvm-svn: 355669
2019-03-08 16:38:25 +08:00
|
|
|
EXPECT_THAT(CDB.getCompileCommand(testPath("foo.cc"))->CommandLine,
|
|
|
|
AllOf(Contains(testPath("foo.cc")), Contains("-DA=1")));
|
2018-11-02 21:09:36 +08:00
|
|
|
EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), llvm::None);
|
|
|
|
|
|
|
|
auto Override = cmd(testPath("foo.cc"), "-DA=3");
|
|
|
|
CDB.setCompileCommand(testPath("foo.cc"), Override);
|
[clangd] Adjust compile commands to be applicable for tooling
Summary:
As can be seen in https://github.com/llvm-mirror/clang/blob/master/lib/Tooling/Tooling.cpp#L385
clang tool invocations adjust commands normally like this. In clangd we have
different code paths for invoking a frontend action(preamble builds, ast builds,
background index, clangd-indexer) they all work on the same GlobalCompilationDatabase
abstraction, but later on are subject to different modifications.
This patch makes sure all of the clangd actions make use of the same compile
commands before invocation.
Enables background-index to work on chromium codebase(since they had dependency
file output in their compile commands).
Reviewers: gribozavr, hokein
Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jdoerfert, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D59086
llvm-svn: 355669
2019-03-08 16:38:25 +08:00
|
|
|
EXPECT_THAT(CDB.getCompileCommand(testPath("foo.cc"))->CommandLine,
|
|
|
|
Contains("-DA=3"));
|
2018-11-02 21:09:36 +08:00
|
|
|
EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), llvm::None);
|
|
|
|
CDB.setCompileCommand(testPath("missing.cc"), Override);
|
[clangd] Adjust compile commands to be applicable for tooling
Summary:
As can be seen in https://github.com/llvm-mirror/clang/blob/master/lib/Tooling/Tooling.cpp#L385
clang tool invocations adjust commands normally like this. In clangd we have
different code paths for invoking a frontend action(preamble builds, ast builds,
background index, clangd-indexer) they all work on the same GlobalCompilationDatabase
abstraction, but later on are subject to different modifications.
This patch makes sure all of the clangd actions make use of the same compile
commands before invocation.
Enables background-index to work on chromium codebase(since they had dependency
file output in their compile commands).
Reviewers: gribozavr, hokein
Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jdoerfert, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D59086
llvm-svn: 355669
2019-03-08 16:38:25 +08:00
|
|
|
EXPECT_THAT(CDB.getCompileCommand(testPath("missing.cc"))->CommandLine,
|
|
|
|
Contains("-DA=3"));
|
2018-11-02 21:09:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(OverlayCDBTest, GetFallbackCommand) {
|
|
|
|
OverlayCDB CDB(Base.get(), {"-DA=4"});
|
|
|
|
EXPECT_THAT(CDB.getFallbackCommand(testPath("bar.cc")).CommandLine,
|
2019-06-04 21:38:36 +08:00
|
|
|
ElementsAre("clang", "-DA=2", testPath("bar.cc"), "-DA=4",
|
|
|
|
"-fsyntax-only", StartsWith("-resource-dir")));
|
2018-11-02 21:09:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(OverlayCDBTest, NoBase) {
|
2019-01-22 17:10:20 +08:00
|
|
|
OverlayCDB CDB(nullptr, {"-DA=6"}, std::string(""));
|
2018-11-02 21:09:36 +08:00
|
|
|
EXPECT_EQ(CDB.getCompileCommand(testPath("bar.cc")), None);
|
|
|
|
auto Override = cmd(testPath("bar.cc"), "-DA=5");
|
|
|
|
CDB.setCompileCommand(testPath("bar.cc"), Override);
|
[clangd] Adjust compile commands to be applicable for tooling
Summary:
As can be seen in https://github.com/llvm-mirror/clang/blob/master/lib/Tooling/Tooling.cpp#L385
clang tool invocations adjust commands normally like this. In clangd we have
different code paths for invoking a frontend action(preamble builds, ast builds,
background index, clangd-indexer) they all work on the same GlobalCompilationDatabase
abstraction, but later on are subject to different modifications.
This patch makes sure all of the clangd actions make use of the same compile
commands before invocation.
Enables background-index to work on chromium codebase(since they had dependency
file output in their compile commands).
Reviewers: gribozavr, hokein
Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jdoerfert, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D59086
llvm-svn: 355669
2019-03-08 16:38:25 +08:00
|
|
|
EXPECT_THAT(CDB.getCompileCommand(testPath("bar.cc"))->CommandLine,
|
|
|
|
Contains("-DA=5"));
|
2018-11-02 21:09:36 +08:00
|
|
|
|
|
|
|
EXPECT_THAT(CDB.getFallbackCommand(testPath("foo.cc")).CommandLine,
|
2019-06-04 21:38:36 +08:00
|
|
|
ElementsAre(EndsWith("clang"), testPath("foo.cc"), "-DA=6",
|
|
|
|
"-fsyntax-only"));
|
2018-11-02 21:09:36 +08:00
|
|
|
}
|
|
|
|
|
2018-11-20 18:56:03 +08:00
|
|
|
TEST_F(OverlayCDBTest, Watch) {
|
|
|
|
OverlayCDB Inner(nullptr);
|
|
|
|
OverlayCDB Outer(&Inner);
|
|
|
|
|
|
|
|
std::vector<std::vector<std::string>> Changes;
|
|
|
|
auto Sub = Outer.watch([&](const std::vector<std::string> &ChangedFiles) {
|
|
|
|
Changes.push_back(ChangedFiles);
|
|
|
|
});
|
|
|
|
|
|
|
|
Inner.setCompileCommand("A.cpp", tooling::CompileCommand());
|
|
|
|
Outer.setCompileCommand("B.cpp", tooling::CompileCommand());
|
|
|
|
Inner.setCompileCommand("A.cpp", llvm::None);
|
|
|
|
Outer.setCompileCommand("C.cpp", llvm::None);
|
|
|
|
EXPECT_THAT(Changes, ElementsAre(ElementsAre("A.cpp"), ElementsAre("B.cpp"),
|
|
|
|
ElementsAre("A.cpp"), ElementsAre("C.cpp")));
|
|
|
|
}
|
|
|
|
|
[clangd] Adjust compile commands to be applicable for tooling
Summary:
As can be seen in https://github.com/llvm-mirror/clang/blob/master/lib/Tooling/Tooling.cpp#L385
clang tool invocations adjust commands normally like this. In clangd we have
different code paths for invoking a frontend action(preamble builds, ast builds,
background index, clangd-indexer) they all work on the same GlobalCompilationDatabase
abstraction, but later on are subject to different modifications.
This patch makes sure all of the clangd actions make use of the same compile
commands before invocation.
Enables background-index to work on chromium codebase(since they had dependency
file output in their compile commands).
Reviewers: gribozavr, hokein
Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jdoerfert, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D59086
llvm-svn: 355669
2019-03-08 16:38:25 +08:00
|
|
|
TEST_F(OverlayCDBTest, Adjustments) {
|
|
|
|
OverlayCDB CDB(Base.get(), {}, std::string(""));
|
|
|
|
auto Cmd = CDB.getCompileCommand(testPath("foo.cc")).getValue();
|
|
|
|
// Delete the file name.
|
|
|
|
Cmd.CommandLine.pop_back();
|
|
|
|
|
|
|
|
// Check dependency file commands are dropped.
|
|
|
|
Cmd.CommandLine.push_back("-MF");
|
|
|
|
Cmd.CommandLine.push_back("random-dependency");
|
|
|
|
|
|
|
|
// Check plugin-related commands are dropped.
|
|
|
|
Cmd.CommandLine.push_back("-Xclang");
|
|
|
|
Cmd.CommandLine.push_back("-load");
|
|
|
|
Cmd.CommandLine.push_back("-Xclang");
|
|
|
|
Cmd.CommandLine.push_back("random-plugin");
|
|
|
|
|
|
|
|
Cmd.CommandLine.push_back("-DA=5");
|
|
|
|
Cmd.CommandLine.push_back(Cmd.Filename);
|
|
|
|
|
|
|
|
CDB.setCompileCommand(testPath("foo.cc"), Cmd);
|
|
|
|
|
|
|
|
EXPECT_THAT(CDB.getCompileCommand(testPath("foo.cc"))->CommandLine,
|
|
|
|
AllOf(Contains("-fsyntax-only"), Contains("-DA=5"),
|
|
|
|
Contains(testPath("foo.cc")), Not(Contains("-MF")),
|
|
|
|
Not(Contains("random-dependency")),
|
|
|
|
Not(Contains("-Xclang")), Not(Contains("-load")),
|
|
|
|
Not(Contains("random-plugin"))));
|
|
|
|
}
|
|
|
|
|
2019-07-11 17:54:31 +08:00
|
|
|
TEST(GlobalCompilationDatabaseTest, DiscoveryWithNestedCDBs) {
|
|
|
|
const char *const CDBOuter =
|
|
|
|
R"cdb(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"file": "a.cc",
|
|
|
|
"command": "",
|
|
|
|
"directory": "{0}",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"file": "build/gen.cc",
|
|
|
|
"command": "",
|
|
|
|
"directory": "{0}",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"file": "build/gen2.cc",
|
|
|
|
"command": "",
|
|
|
|
"directory": "{0}",
|
|
|
|
}
|
|
|
|
]
|
|
|
|
)cdb";
|
|
|
|
const char *const CDBInner =
|
|
|
|
R"cdb(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"file": "gen.cc",
|
|
|
|
"command": "",
|
|
|
|
"directory": "{0}/build",
|
|
|
|
}
|
|
|
|
]
|
|
|
|
)cdb";
|
|
|
|
class CleaningFS {
|
|
|
|
public:
|
|
|
|
llvm::SmallString<128> Root;
|
|
|
|
|
|
|
|
CleaningFS() {
|
|
|
|
EXPECT_FALSE(
|
|
|
|
llvm::sys::fs::createUniqueDirectory("clangd-cdb-test", Root))
|
|
|
|
<< "Failed to create unique directory";
|
|
|
|
}
|
|
|
|
|
|
|
|
~CleaningFS() {
|
|
|
|
EXPECT_FALSE(llvm::sys::fs::remove_directories(Root))
|
|
|
|
<< "Failed to cleanup " << Root;
|
|
|
|
}
|
|
|
|
|
|
|
|
void registerFile(PathRef RelativePath, llvm::StringRef Contents) {
|
|
|
|
llvm::SmallString<128> AbsPath(Root);
|
|
|
|
llvm::sys::path::append(AbsPath, RelativePath);
|
|
|
|
|
|
|
|
EXPECT_FALSE(llvm::sys::fs::create_directories(
|
|
|
|
llvm::sys::path::parent_path(AbsPath)))
|
|
|
|
<< "Failed to create directories for: " << AbsPath;
|
|
|
|
|
|
|
|
std::error_code EC;
|
|
|
|
llvm::raw_fd_ostream OS(AbsPath, EC);
|
|
|
|
EXPECT_FALSE(EC) << "Failed to open " << AbsPath << " for writing";
|
|
|
|
OS << llvm::formatv(Contents.data(),
|
|
|
|
llvm::sys::path::convert_to_slash(Root));
|
|
|
|
OS.close();
|
|
|
|
|
|
|
|
EXPECT_FALSE(OS.has_error());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
CleaningFS FS;
|
|
|
|
FS.registerFile("compile_commands.json", CDBOuter);
|
|
|
|
FS.registerFile("build/compile_commands.json", CDBInner);
|
2019-07-11 18:41:58 +08:00
|
|
|
llvm::SmallString<128> File;
|
2019-07-11 17:54:31 +08:00
|
|
|
|
|
|
|
// Note that gen2.cc goes missing with our following model, not sure this
|
|
|
|
// happens in practice though.
|
|
|
|
{
|
|
|
|
DirectoryBasedGlobalCompilationDatabase DB(llvm::None);
|
|
|
|
std::vector<std::string> DiscoveredFiles;
|
|
|
|
auto Sub =
|
|
|
|
DB.watch([&DiscoveredFiles](const std::vector<std::string> Changes) {
|
|
|
|
DiscoveredFiles = Changes;
|
|
|
|
});
|
2019-07-11 18:41:58 +08:00
|
|
|
|
|
|
|
File = FS.Root;
|
|
|
|
llvm::sys::path::append(File, "a.cc");
|
|
|
|
DB.getCompileCommand(File.str());
|
2019-07-11 17:54:31 +08:00
|
|
|
EXPECT_THAT(DiscoveredFiles, UnorderedElementsAre(EndsWith("a.cc")));
|
2019-07-11 18:41:58 +08:00
|
|
|
DiscoveredFiles.clear();
|
2019-07-11 17:54:31 +08:00
|
|
|
|
2019-07-11 18:41:58 +08:00
|
|
|
File = FS.Root;
|
|
|
|
llvm::sys::path::append(File, "build", "gen.cc");
|
|
|
|
DB.getCompileCommand(File.str());
|
2019-07-11 17:54:31 +08:00
|
|
|
EXPECT_THAT(DiscoveredFiles, UnorderedElementsAre(EndsWith("gen.cc")));
|
|
|
|
}
|
|
|
|
|
|
|
|
// With a custom compile commands dir.
|
|
|
|
{
|
|
|
|
DirectoryBasedGlobalCompilationDatabase DB(FS.Root.str().str());
|
|
|
|
std::vector<std::string> DiscoveredFiles;
|
|
|
|
auto Sub =
|
|
|
|
DB.watch([&DiscoveredFiles](const std::vector<std::string> Changes) {
|
|
|
|
DiscoveredFiles = Changes;
|
|
|
|
});
|
2019-07-11 18:41:58 +08:00
|
|
|
|
|
|
|
File = FS.Root;
|
|
|
|
llvm::sys::path::append(File, "a.cc");
|
|
|
|
DB.getCompileCommand(File.str());
|
2019-07-11 17:54:31 +08:00
|
|
|
EXPECT_THAT(DiscoveredFiles,
|
|
|
|
UnorderedElementsAre(EndsWith("a.cc"), EndsWith("gen.cc"),
|
|
|
|
EndsWith("gen2.cc")));
|
|
|
|
DiscoveredFiles.clear();
|
2019-07-11 18:41:58 +08:00
|
|
|
|
|
|
|
File = FS.Root;
|
|
|
|
llvm::sys::path::append(File, "build", "gen.cc");
|
|
|
|
DB.getCompileCommand(File.str());
|
2019-07-11 17:54:31 +08:00
|
|
|
EXPECT_THAT(DiscoveredFiles, IsEmpty());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-20 19:35:17 +08:00
|
|
|
} // namespace
|
|
|
|
} // namespace clangd
|
|
|
|
} // namespace clang
|