mirror of
https://github.com/RPCS3/llvm.git
synced 2025-04-12 11:03:24 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188125 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3ed7576a3b
commit
0a69bac396
@ -298,6 +298,18 @@ UniqueID file_status::getUniqueID() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
error_code current_path(SmallVectorImpl<char> &result) {
|
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
|
#ifdef MAXPATHLEN
|
||||||
result.reserve(MAXPATHLEN);
|
result.reserve(MAXPATHLEN);
|
||||||
#else
|
#else
|
||||||
|
@ -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-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
|
// RUN: llvm-dwarfdump -debug-dump=info %t.o | FileCheck %s
|
||||||
|
|
||||||
// CHECK: DW_AT_comp_dir [DW_FORM_string] ("{{([A-Za-z]:.*)?}}/test/comp/dir")
|
// 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:
|
f:
|
||||||
nop
|
nop
|
||||||
|
Loading…
x
Reference in New Issue
Block a user