summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Unix
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2011-07-29 04:42:39 +0000
committerNick Lewycky <nicholas@mxc.ca>2011-07-29 04:42:39 +0000
commit38b9b568b950d2c200e1de2e9cb87d5f8ff6d59f (patch)
tree52f7158a8274a66d56dbbb9df50cea19934dd7b6 /llvm/lib/Support/Unix
parent019d255d3e0041d70f2a59303013d9337dd980a2 (diff)
downloadbcm5719-llvm-38b9b568b950d2c200e1de2e9cb87d5f8ff6d59f.tar.gz
bcm5719-llvm-38b9b568b950d2c200e1de2e9cb87d5f8ff6d59f.zip
Teach Path::GetCurrentDirectory to use $PWD, to support users who like to do
screwy things by setting PWD != getcwd(). For example, some developers I know will use this to control the value in gcc's DW_AT_comp_dir value in debug output. With this patch, that trick will now work on clang too. The only other effect of this change is that the static analysis will now respect $PWD when reporting the directory of the files in its HTML output. I think that's fine. llvm-svn: 136459
Diffstat (limited to 'llvm/lib/Support/Unix')
-rw-r--r--llvm/lib/Support/Unix/Path.inc7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
index f295b92e4a5..a139399cba3 100644
--- a/llvm/lib/Support/Unix/Path.inc
+++ b/llvm/lib/Support/Unix/Path.inc
@@ -251,9 +251,12 @@ Path::GetUserHomeDirectory() {
Path
Path::GetCurrentDirectory() {
+ if (char *pwd = getenv("PWD"))
+ return Path(pwd);
+
char pathname[MAXPATHLEN];
- if (!getcwd(pathname,MAXPATHLEN)) {
- assert (false && "Could not query current working directory.");
+ if (!getcwd(pathname, MAXPATHLEN)) {
+ assert(false && "Could not query current working directory.");
return Path();
}
OpenPOWER on IntegriCloud