summaryrefslogtreecommitdiffstats
path: root/unittests/clangd/ClangdTests.cpp
diff options
context:
space:
mode:
authorJordan Rupprecht <rupprecht@google.com>2019-01-18 19:46:00 +0000
committerJordan Rupprecht <rupprecht@google.com>2019-01-18 19:46:00 +0000
commit5026a9a16d10a2edf09be54c7225f49b5789c69e (patch)
tree85c1e1c98d2a81ed687b44f5dd2c917176506ae8 /unittests/clangd/ClangdTests.cpp
parentc0c923fb4d65ab16332fc84188b46508de0c35af (diff)
parent53b849a7ec90500d4c5970f3624c9a5321aacb16 (diff)
Creating branches/google/stable and tags/google/stable/2019-01-18 from r351319
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/branches/google/stable@351578 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/clangd/ClangdTests.cpp')
-rw-r--r--unittests/clangd/ClangdTests.cpp55
1 files changed, 27 insertions, 28 deletions
diff --git a/unittests/clangd/ClangdTests.cpp b/unittests/clangd/ClangdTests.cpp
index 7f954fd8..c1cc623a 100644
--- a/unittests/clangd/ClangdTests.cpp
+++ b/unittests/clangd/ClangdTests.cpp
@@ -30,7 +30,6 @@
#include <thread>
#include <vector>
-using namespace llvm;
namespace clang {
namespace clangd {
@@ -109,14 +108,14 @@ public:
private:
mutable std::mutex Mutex;
- StringMap<bool> LastDiagsHadError;
+ llvm::StringMap<bool> LastDiagsHadError;
};
/// Replaces all patterns of the form 0x123abc with spaces
std::string replacePtrsInDump(std::string const &Dump) {
- Regex RE("0x[0-9a-fA-F]+");
- SmallVector<StringRef, 1> Matches;
- StringRef Pending = Dump;
+ llvm::Regex RE("0x[0-9a-fA-F]+");
+ llvm::SmallVector<llvm::StringRef, 1> Matches;
+ llvm::StringRef Pending = Dump;
std::string Result;
while (RE.match(Pending, &Matches)) {
@@ -139,8 +138,8 @@ std::string dumpASTWithoutMemoryLocs(ClangdServer &Server, PathRef File) {
class ClangdVFSTest : public ::testing::Test {
protected:
std::string parseSourceAndDumpAST(
- PathRef SourceFileRelPath, StringRef SourceContents,
- std::vector<std::pair<PathRef, StringRef>> ExtraFiles = {},
+ PathRef SourceFileRelPath, llvm::StringRef SourceContents,
+ std::vector<std::pair<PathRef, llvm::StringRef>> ExtraFiles = {},
bool ExpectErrors = false) {
MockFSProvider FS;
ErrorCheckingDiagConsumer DiagConsumer;
@@ -269,7 +268,7 @@ int b = a;
TEST_F(ClangdVFSTest, PropagatesContexts) {
static Key<int> Secret;
struct FSProvider : public FileSystemProvider {
- IntrusiveRefCntPtr<vfs::FileSystem> getFileSystem() const override {
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> getFileSystem() const override {
Got = Context::current().getExisting(Secret);
return buildTestFS({});
}
@@ -313,19 +312,19 @@ TEST_F(ClangdVFSTest, SearchLibDir) {
// A lib dir for gcc installation
SmallString<64> LibDir("/randomusr/lib/gcc/x86_64-linux-gnu");
- sys::path::append(LibDir, Version);
+ llvm::sys::path::append(LibDir, Version);
// Put crtbegin.o into LibDir/64 to trick clang into thinking there's a gcc
// installation there.
SmallString<64> DummyLibFile;
- sys::path::append(DummyLibFile, LibDir, "64", "crtbegin.o");
+ llvm::sys::path::append(DummyLibFile, LibDir, "64", "crtbegin.o");
FS.Files[DummyLibFile] = "";
SmallString<64> IncludeDir("/randomusr/include/c++");
- sys::path::append(IncludeDir, Version);
+ llvm::sys::path::append(IncludeDir, Version);
SmallString<64> StringPath;
- sys::path::append(StringPath, IncludeDir, "string");
+ llvm::sys::path::append(StringPath, IncludeDir, "string");
FS.Files[StringPath] = "class mock_string {};";
auto FooCpp = testPath("foo.cpp");
@@ -477,8 +476,8 @@ int hello;
Locations = runFindDefinitions(Server, FooCpp, FooSource.point());
EXPECT_TRUE(bool(Locations));
- EXPECT_THAT(*Locations, ElementsAre(FileRange(FooCpp,
- FooSource.range("two"))));
+ EXPECT_THAT(*Locations,
+ ElementsAre(FileRange(FooCpp, FooSource.range("two"))));
}
TEST_F(ClangdVFSTest, MemoryUsage) {
@@ -598,7 +597,7 @@ int d;
void onDiagnosticsReady(PathRef File,
std::vector<Diag> Diagnostics) override {
- StringRef FileIndexStr = sys::path::stem(File);
+ StringRef FileIndexStr = llvm::sys::path::stem(File);
ASSERT_TRUE(FileIndexStr.consume_front("Foo"));
unsigned long FileIndex = std::stoul(FileIndexStr.str());
@@ -976,28 +975,28 @@ TEST_F(ClangdVFSTest, ChangedHeaderFromISystem) {
TEST(ClangdTests, PreambleVFSStatCache) {
class ListenStatsFSProvider : public FileSystemProvider {
public:
- ListenStatsFSProvider(StringMap<unsigned> &CountStats)
+ ListenStatsFSProvider(llvm::StringMap<unsigned> &CountStats)
: CountStats(CountStats) {}
- IntrusiveRefCntPtr<vfs::FileSystem> getFileSystem() const override {
- class ListenStatVFS : public vfs::ProxyFileSystem {
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> getFileSystem() const override {
+ class ListenStatVFS : public llvm::vfs::ProxyFileSystem {
public:
- ListenStatVFS(IntrusiveRefCntPtr<vfs::FileSystem> FS,
- StringMap<unsigned> &CountStats)
+ ListenStatVFS(IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS,
+ llvm::StringMap<unsigned> &CountStats)
: ProxyFileSystem(std::move(FS)), CountStats(CountStats) {}
- ErrorOr<std::unique_ptr<vfs::File>>
+ llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
openFileForRead(const Twine &Path) override {
- ++CountStats[sys::path::filename(Path.str())];
+ ++CountStats[llvm::sys::path::filename(Path.str())];
return ProxyFileSystem::openFileForRead(Path);
}
- ErrorOr<vfs::Status> status(const Twine &Path) override {
- ++CountStats[sys::path::filename(Path.str())];
+ llvm::ErrorOr<llvm::vfs::Status> status(const Twine &Path) override {
+ ++CountStats[llvm::sys::path::filename(Path.str())];
return ProxyFileSystem::status(Path);
}
private:
- StringMap<unsigned> &CountStats;
+ llvm::StringMap<unsigned> &CountStats;
};
return IntrusiveRefCntPtr<ListenStatVFS>(
@@ -1005,11 +1004,11 @@ TEST(ClangdTests, PreambleVFSStatCache) {
}
// If relative paths are used, they are resolved with testPath().
- StringMap<std::string> Files;
- StringMap<unsigned> &CountStats;
+ llvm::StringMap<std::string> Files;
+ llvm::StringMap<unsigned> &CountStats;
};
- StringMap<unsigned> CountStats;
+ llvm::StringMap<unsigned> CountStats;
ListenStatsFSProvider FS(CountStats);
ErrorCheckingDiagConsumer DiagConsumer;
MockCompilationDatabase CDB;