diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-08-10 00:50:57 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-08-10 00:50:57 +0000 |
commit | 6ee163875c5334647d09369f361f207f6a97fc49 (patch) | |
tree | 169a25948cd6afb4adf0f7819de3a839cbe591ff /llvm/lib/Support | |
parent | 0ec71a0c01a85b7718aca0517ef0d985001fdde8 (diff) | |
download | bcm5719-llvm-6ee163875c5334647d09369f361f207f6a97fc49.tar.gz bcm5719-llvm-6ee163875c5334647d09369f361f207f6a97fc49.zip |
Check for $PWD in llvm::sys::current_path.
Some users (clang, libTooling) require this. After this patch we can remove
the calls to getenv("PWD") from clang.
llvm-svn: 188125
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r-- | llvm/lib/Support/Unix/Path.inc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc index 4dcfa094a7b..f6a137e7a0b 100644 --- a/llvm/lib/Support/Unix/Path.inc +++ b/llvm/lib/Support/Unix/Path.inc @@ -298,6 +298,18 @@ UniqueID file_status::getUniqueID() const { } error_code current_path(SmallVectorImpl<char> &result) { + result.clear(); + + const char *pwd = ::getenv("PWD"); + llvm::sys::fs::file_status PWDStatus, DotStatus; + if (pwd && llvm::sys::path::is_absolute(pwd) && + !llvm::sys::fs::status(pwd, PWDStatus) && + !llvm::sys::fs::status(".", DotStatus) && + PWDStatus.getUniqueID() == DotStatus.getUniqueID()) { + result.append(pwd, pwd + strlen(pwd)); + return error_code::success(); + } + #ifdef MAXPATHLEN result.reserve(MAXPATHLEN); #else |