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
This commit is contained in:
Nick Lewycky 2011-07-29 04:42:39 +00:00
parent 019d255d3e
commit 38b9b568b9
1 changed files with 5 additions and 2 deletions

View File

@ -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();
}