Tooling.cpp: Don't refer to $ENV{PWD}. Use llvm::sys::fs instead.

$ENV{PWD} is not expected to be set on all hosts.

llvm-svn: 154015
This commit is contained in:
NAKAMURA Takumi 2012-04-04 13:59:36 +00:00
parent e1fd20172b
commit f0c8779db4
1 changed files with 3 additions and 1 deletions

View File

@ -24,6 +24,7 @@
#include "clang/Frontend/FrontendAction.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/Frontend/TextDiagnosticPrinter.h"
#include "llvm/Support/FileSystem.h"
namespace clang {
namespace tooling {
@ -235,7 +236,8 @@ void ToolInvocation::addFileMappingsTo(SourceManager &Sources) {
ClangTool::ClangTool(const CompilationDatabase &Compilations,
ArrayRef<std::string> SourcePaths)
: Files((FileSystemOptions())) {
StringRef BaseDirectory(::getenv("PWD"));
llvm::SmallString<1024> BaseDirectory;
llvm::sys::fs::current_path(BaseDirectory);
for (unsigned I = 0, E = SourcePaths.size(); I != E; ++I) {
llvm::SmallString<1024> File(getAbsolutePath(
SourcePaths[I], BaseDirectory));