From ad54935c7781008d3ad780767aec309f28360ff9 Mon Sep 17 00:00:00 2001 From: Kadir Cetinkaya Date: Thu, 11 Jul 2019 09:54:31 +0000 Subject: [clangd] Reland rL365634 This was reverted in rL365678, the failure was due to YAML parsing of compile_commands.json. Converting backslashes to forward slashes to fix the issue in unittest. llvm-svn: 365748 --- clang-tools-extra/clangd/unittests/TestFS.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'clang-tools-extra/clangd/unittests/TestFS.cpp') diff --git a/clang-tools-extra/clangd/unittests/TestFS.cpp b/clang-tools-extra/clangd/unittests/TestFS.cpp index c5b2613f759..5f5c5c21794 100644 --- a/clang-tools-extra/clangd/unittests/TestFS.cpp +++ b/clang-tools-extra/clangd/unittests/TestFS.cpp @@ -6,7 +6,11 @@ // //===----------------------------------------------------------------------===// #include "TestFS.h" +#include "GlobalCompilationDatabase.h" +#include "Path.h" #include "URI.h" +#include "llvm/ADT/None.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Errc.h" #include "llvm/Support/Path.h" @@ -36,9 +40,13 @@ MockCompilationDatabase::MockCompilationDatabase(llvm::StringRef Directory, // -ffreestanding avoids implicit stdc-predef.h. } +llvm::Optional +MockCompilationDatabase::getProjectInfo(PathRef File) const { + return ProjectInfo{Directory}; +}; + llvm::Optional -MockCompilationDatabase::getCompileCommand(PathRef File, - ProjectInfo *Project) const { +MockCompilationDatabase::getCompileCommand(PathRef File) const { if (ExtraClangFlags.empty()) return None; @@ -57,8 +65,6 @@ MockCompilationDatabase::getCompileCommand(PathRef File, CommandLine.push_back(RelativeFilePath.str()); } - if (Project) - Project->SourceRoot = Directory; return {tooling::CompileCommand(Directory != llvm::StringRef() ? Directory : llvm::sys::path::parent_path(File), -- cgit v1.2.3