diff options
author | Kadir Cetinkaya <kadircet@google.com> | 2019-12-04 15:50:27 +0100 |
---|---|---|
committer | Kadir Cetinkaya <kadircet@google.com> | 2019-12-04 15:58:01 +0100 |
commit | 0f12f9096e1e33d88cb0b5601b0e035a2674c19a (patch) | |
tree | ef1bbf1c7c09d5c6d0d282fed514be89f6f37028 /clang | |
parent | 95b2e516bd3e4587953e44bf062054ff84f2b057 (diff) | |
download | bcm5719-llvm-0f12f9096e1e33d88cb0b5601b0e035a2674c19a.tar.gz bcm5719-llvm-0f12f9096e1e33d88cb0b5601b0e035a2674c19a.zip |
Revert "[llvm][Support] Take in CurrentDirectory as a parameter in ExpandResponseFiles"
This reverts commit 75656005dbc8866e1888932a68a830b0df403560.
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/Tooling/CompilationDatabase.h | 1 | ||||
-rw-r--r-- | clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp | 10 | ||||
-rw-r--r-- | clang/lib/Tooling/JSONCompilationDatabase.cpp | 4 |
3 files changed, 10 insertions, 5 deletions
diff --git a/clang/include/clang/Tooling/CompilationDatabase.h b/clang/include/clang/Tooling/CompilationDatabase.h index b28a8a6d6e5..6f794e51787 100644 --- a/clang/include/clang/Tooling/CompilationDatabase.h +++ b/clang/include/clang/Tooling/CompilationDatabase.h @@ -222,6 +222,7 @@ inferTargetAndDriverMode(std::unique_ptr<CompilationDatabase> Base); /// Returns a wrapped CompilationDatabase that will expand all rsp(response) /// files on commandline returned by underlying database. +/// Note: This may change the working directory of FS. std::unique_ptr<CompilationDatabase> expandResponseFiles(std::unique_ptr<CompilationDatabase> Base, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS); diff --git a/clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp b/clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp index 84936ba05b2..bb519277dfa 100644 --- a/clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp +++ b/clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "clang/Tooling/CompilationDatabase.h" -#include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ConvertUTF.h" @@ -48,6 +47,12 @@ public: private: std::vector<CompileCommand> expand(std::vector<CompileCommand> Cmds) const { for (auto &Cmd : Cmds) { + // FIXME: we should rather propagate the current directory into + // ExpandResponseFiles as well in addition to FS. + if (std::error_code EC = FS->setCurrentWorkingDirectory(Cmd.Directory)) { + llvm::consumeError(llvm::errorCodeToError(EC)); + continue; + } bool SeenRSPFile = false; llvm::SmallVector<const char *, 20> Argv; Argv.reserve(Cmd.CommandLine.size()); @@ -59,8 +64,7 @@ private: continue; llvm::BumpPtrAllocator Alloc; llvm::StringSaver Saver(Alloc); - llvm::cl::ExpandResponseFiles(Saver, Tokenizer, Argv, false, false, *FS, - llvm::StringRef(Cmd.Directory)); + llvm::cl::ExpandResponseFiles(Saver, Tokenizer, Argv, false, false, *FS); Cmd.CommandLine.assign(Argv.begin(), Argv.end()); } return Cmds; diff --git a/clang/lib/Tooling/JSONCompilationDatabase.cpp b/clang/lib/Tooling/JSONCompilationDatabase.cpp index 04dd4dbf624..8dd46083902 100644 --- a/clang/lib/Tooling/JSONCompilationDatabase.cpp +++ b/clang/lib/Tooling/JSONCompilationDatabase.cpp @@ -29,7 +29,6 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" #include "llvm/Support/StringSaver.h" -#include "llvm/Support/VirtualFileSystem.h" #include "llvm/Support/YAMLParser.h" #include "llvm/Support/raw_ostream.h" #include <cassert> @@ -170,7 +169,8 @@ class JSONCompilationDatabasePlugin : public CompilationDatabasePlugin { JSONDatabasePath, ErrorMessage, JSONCommandLineSyntax::AutoDetect); return Base ? inferTargetAndDriverMode( inferMissingCompileCommands(expandResponseFiles( - std::move(Base), llvm::vfs::getRealFileSystem()))) + std::move(Base), + llvm::vfs::createPhysicalFileSystem().release()))) : nullptr; } }; |