[llvm] r188125 - Check for $PWD in llvm::sys::current_path.
Rafael Espindola
rafael.espindola at gmail.com
Fri Aug 9 17:50:57 PDT 2013
Author: rafael
Date: Fri Aug 9 19:50:57 2013
New Revision: 188125
URL: http://llvm.org/viewvc/llvm-project?rev=188125&view=rev
Log:
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.
Modified:
llvm/trunk/lib/Support/Unix/Path.inc
llvm/trunk/test/MC/ELF/comp-dir.s
Modified: llvm/trunk/lib/Support/Unix/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Path.inc?rev=188125&r1=188124&r2=188125&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/Path.inc (original)
+++ llvm/trunk/lib/Support/Unix/Path.inc Fri Aug 9 19:50:57 2013
@@ -298,6 +298,18 @@ UniqueID file_status::getUniqueID() cons
}
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
Modified: llvm/trunk/test/MC/ELF/comp-dir.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/comp-dir.s?rev=188125&r1=188124&r2=188125&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/comp-dir.s (original)
+++ llvm/trunk/test/MC/ELF/comp-dir.s Fri Aug 9 19:50:57 2013
@@ -1,7 +1,17 @@
+// REQUIRES: shell
+// XFAIL: mingw
// RUN: llvm-mc -triple=x86_64-linux-unknown -g -fdebug-compilation-dir=/test/comp/dir %s -filetype=obj -o %t.o
// RUN: llvm-dwarfdump -debug-dump=info %t.o | FileCheck %s
// CHECK: DW_AT_comp_dir [DW_FORM_string] ("{{([A-Za-z]:.*)?}}/test/comp/dir")
+// RUN: mkdir -p %t.foo
+// RUN: ln -sf %t.foo %t.bar
+// RUN: cd %t.foo
+// RUN: env PWD=%t.bar llvm-mc -triple=x86_64-linux-unknown -g %s -filetype=obj -o %t.o
+// RUN: llvm-dwarfdump -debug-dump=info %t.o | FileCheck --check-prefix=PWD %s
+// PWD: DW_AT_comp_dir [DW_FORM_string] ("{{.*}}.bar")
+
+
f:
nop
More information about the llvm-commits
mailing list