From c156806844509e3a7309ddae8765c7dfdafe892b Mon Sep 17 00:00:00 2001 From: Sam McCall Date: Fri, 16 Feb 2018 09:41:43 +0000 Subject: [clangd] TestFS cleanup: getVirtualBlahBlah -> testPath/testRoot. Remove SmallString micro-opt for more ergonomic tests. NFC llvm-svn: 325326 --- clang-tools-extra/unittests/clangd/TestFS.cpp | 31 +++++++++++++++------------ 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'clang-tools-extra/unittests/clangd/TestFS.cpp') diff --git a/clang-tools-extra/unittests/clangd/TestFS.cpp b/clang-tools-extra/unittests/clangd/TestFS.cpp index 38cef894074..197c93feb18 100644 --- a/clang-tools-extra/unittests/clangd/TestFS.cpp +++ b/clang-tools-extra/unittests/clangd/TestFS.cpp @@ -12,14 +12,17 @@ namespace clang { namespace clangd { +using namespace llvm; + IntrusiveRefCntPtr -buildTestFS(llvm::StringMap const &Files) { +buildTestFS(StringMap const &Files) { IntrusiveRefCntPtr MemFS( new vfs::InMemoryFileSystem); - for (auto &FileAndContents : Files) + for (auto &FileAndContents : Files) { MemFS->addFile(FileAndContents.first(), time_t(), - llvm::MemoryBuffer::getMemBuffer(FileAndContents.second, - FileAndContents.first())); + MemoryBuffer::getMemBuffer(FileAndContents.second, + FileAndContents.first())); + } return MemFS; } @@ -38,20 +41,20 @@ MockCompilationDatabase::MockCompilationDatabase(bool UseRelPaths) // -ffreestanding avoids implicit stdc-predef.h. } -llvm::Optional +Optional MockCompilationDatabase::getCompileCommand(PathRef File) const { if (ExtraClangFlags.empty()) - return llvm::None; + return None; auto CommandLine = ExtraClangFlags; - auto FileName = llvm::sys::path::filename(File); + auto FileName = sys::path::filename(File); CommandLine.insert(CommandLine.begin(), "clang"); CommandLine.insert(CommandLine.end(), UseRelPaths ? FileName : File); - return {tooling::CompileCommand(llvm::sys::path::parent_path(File), FileName, + return {tooling::CompileCommand(sys::path::parent_path(File), FileName, std::move(CommandLine), "")}; } -const char *getVirtualTestRoot() { +const char *testRoot() { #ifdef LLVM_ON_WIN32 return "C:\\clangd-test"; #else @@ -59,12 +62,12 @@ const char *getVirtualTestRoot() { #endif } -llvm::SmallString<32> getVirtualTestFilePath(PathRef File) { - assert(llvm::sys::path::is_relative(File) && "FileName should be relative"); +std::string testPath(PathRef File) { + assert(sys::path::is_relative(File) && "FileName should be relative"); - llvm::SmallString<32> Path; - llvm::sys::path::append(Path, getVirtualTestRoot(), File); - return Path; + SmallString<32> Path; + sys::path::append(Path, testRoot(), File); + return Path.str(); } } // namespace clangd -- cgit v1.2.3