summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-08-10 01:40:10 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-08-10 01:40:10 +0000
commitc7367ffdab078477e97e9d3ba5d69e818e0b41f1 (patch)
tree19de96081d47dcd59ac4d35f1bbb67d7b5baabc5 /clang/lib
parent7964ab5a434ab38b188bb315437150858fa57026 (diff)
downloadbcm5719-llvm-c7367ffdab078477e97e9d3ba5d69e818e0b41f1.tar.gz
bcm5719-llvm-c7367ffdab078477e97e9d3ba5d69e818e0b41f1.zip
Simplify now that llvm::sys::current_path checks $PWD.
llvm-svn: 188128
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Driver/Tools.cpp28
-rw-r--r--clang/lib/Tooling/Tooling.cpp17
2 files changed, 10 insertions, 35 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index 2953612f64c..510575b3958 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -1780,24 +1780,8 @@ static bool shouldUseLeafFramePointer(const ArgList &Args,
return true;
}
-/// If the PWD environment variable is set, add a CC1 option to specify the
-/// debug compilation directory.
+/// Add a CC1 option to specify the debug compilation directory.
static void addDebugCompDirArg(const ArgList &Args, ArgStringList &CmdArgs) {
- const char *pwd = ::getenv("PWD");
- if (!pwd)
- return;
-
- llvm::sys::fs::file_status PWDStatus, DotStatus;
- if (llvm::sys::path::is_absolute(pwd) &&
- !llvm::sys::fs::status(pwd, PWDStatus) &&
- !llvm::sys::fs::status(".", DotStatus) &&
- PWDStatus.getUniqueID() == DotStatus.getUniqueID()) {
- CmdArgs.push_back("-fdebug-compilation-dir");
- CmdArgs.push_back(Args.MakeArgString(pwd));
- return;
- }
-
- // Fall back to using getcwd.
SmallString<128> cwd;
if (!llvm::sys::fs::current_path(cwd)) {
CmdArgs.push_back("-fdebug-compilation-dir");
@@ -2494,12 +2478,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-coverage-file");
SmallString<128> CoverageFilename(Output.getFilename());
if (llvm::sys::path::is_relative(CoverageFilename.str())) {
- if (const char *pwd = ::getenv("PWD")) {
- if (llvm::sys::path::is_absolute(pwd)) {
- SmallString<128> Pwd(pwd);
- llvm::sys::path::append(Pwd, CoverageFilename.str());
- CoverageFilename.swap(Pwd);
- }
+ SmallString<128> Pwd;
+ if (!llvm::sys::fs::current_path(Pwd)) {
+ llvm::sys::path::append(Pwd, CoverageFilename.str());
+ CoverageFilename.swap(Pwd);
}
}
CmdArgs.push_back(Args.MakeArgString(CoverageFilename));
diff --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp
index cd4fbc6b5d5..c5fec683844 100644
--- a/clang/lib/Tooling/Tooling.cpp
+++ b/clang/lib/Tooling/Tooling.cpp
@@ -124,23 +124,16 @@ bool runToolOnCodeWithArgs(clang::FrontendAction *ToolAction, const Twine &Code,
}
std::string getAbsolutePath(StringRef File) {
- SmallString<1024> BaseDirectory;
- if (const char *PWD = ::getenv("PWD"))
- BaseDirectory = PWD;
- else
- llvm::sys::fs::current_path(BaseDirectory);
- SmallString<1024> PathStorage;
- if (llvm::sys::path::is_absolute(File)) {
- llvm::sys::path::native(File, PathStorage);
- return PathStorage.str();
- }
StringRef RelativePath(File);
// FIXME: Should '.\\' be accepted on Win32?
if (RelativePath.startswith("./")) {
RelativePath = RelativePath.substr(strlen("./"));
}
- SmallString<1024> AbsolutePath(BaseDirectory);
- llvm::sys::path::append(AbsolutePath, RelativePath);
+
+ SmallString<1024> AbsolutePath = RelativePath;
+ llvm::error_code EC = llvm::sys::fs::make_absolute(AbsolutePath);
+ assert(!EC);
+ SmallString<1024> PathStorage;
llvm::sys::path::native(Twine(AbsolutePath), PathStorage);
return PathStorage.str();
}
OpenPOWER on IntegriCloud