diff options
Diffstat (limited to 'clang-tools-extra/unittests/clangd/ClangdTests.cpp')
| -rw-r--r-- | clang-tools-extra/unittests/clangd/ClangdTests.cpp | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/clang-tools-extra/unittests/clangd/ClangdTests.cpp b/clang-tools-extra/unittests/clangd/ClangdTests.cpp index a32c495b4a8..c1cc623a05a 100644 --- a/clang-tools-extra/unittests/clangd/ClangdTests.cpp +++ b/clang-tools-extra/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"); @@ -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; |

