aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Tooling
diff options
context:
space:
mode:
authorKadir Cetinkaya <kadircet@google.com>2019-11-29 15:37:14 +0100
committerKadir Cetinkaya <kadircet@google.com>2019-12-04 15:13:12 +0100
commit75656005dbc8866e1888932a68a830b0df403560 (patch)
treee8fab392d5c236a8c49e5ab1b6577d5f187db64f /clang/lib/Tooling
parent45ef055d4ffda4d2b04b62f73e36cc6d5252758b (diff)
downloadllvm-75656005dbc8866e1888932a68a830b0df403560.zip
llvm-75656005dbc8866e1888932a68a830b0df403560.tar.gz
llvm-75656005dbc8866e1888932a68a830b0df403560.tar.bz2
[llvm][Support] Take in CurrentDirectory as a parameter in ExpandResponseFiles
Summary: This is a follow-up to D70769 and D70222, which allows propagation of current directory down to ExpandResponseFiles for handling of relative paths. Previously clients had to mutate FS to achieve that, which is not thread-safe and can even be thread-hostile in the case of real file system. Reviewers: sammccall Subscribers: hiraditya, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D70857
Diffstat (limited to 'clang/lib/Tooling')
-rw-r--r--clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp10
-rw-r--r--clang/lib/Tooling/JSONCompilationDatabase.cpp4
2 files changed, 5 insertions, 9 deletions
diff --git a/clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp b/clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
index bb51927..84936ba 100644
--- a/clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
+++ b/clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#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"
@@ -47,12 +48,6 @@ 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());
@@ -64,7 +59,8 @@ private:
continue;
llvm::BumpPtrAllocator Alloc;
llvm::StringSaver Saver(Alloc);
- llvm::cl::ExpandResponseFiles(Saver, Tokenizer, Argv, false, false, *FS);
+ llvm::cl::ExpandResponseFiles(Saver, Tokenizer, Argv, false, false, *FS,
+ llvm::StringRef(Cmd.Directory));
Cmd.CommandLine.assign(Argv.begin(), Argv.end());
}
return Cmds;
diff --git a/clang/lib/Tooling/JSONCompilationDatabase.cpp b/clang/lib/Tooling/JSONCompilationDatabase.cpp
index 8dd4608..04dd4db 100644
--- a/clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ b/clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -29,6 +29,7 @@
#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>
@@ -169,8 +170,7 @@ class JSONCompilationDatabasePlugin : public CompilationDatabasePlugin {
JSONDatabasePath, ErrorMessage, JSONCommandLineSyntax::AutoDetect);
return Base ? inferTargetAndDriverMode(
inferMissingCompileCommands(expandResponseFiles(
- std::move(Base),
- llvm::vfs::createPhysicalFileSystem().release())))
+ std::move(Base), llvm::vfs::getRealFileSystem())))
: nullptr;
}
};