[llvm-commits] [llvm] r136459 - /llvm/trunk/lib/Support/Unix/Path.inc

Nick Lewycky nicholas at mxc.ca
Thu Jul 28 21:42:39 PDT 2011


Author: nicholas
Date: Thu Jul 28 23:42:39 2011
New Revision: 136459

URL: http://llvm.org/viewvc/llvm-project?rev=136459&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/Support/Unix/Path.inc

Modified: llvm/trunk/lib/Support/Unix/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Path.inc?rev=136459&r1=136458&r2=136459&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/Path.inc (original)
+++ llvm/trunk/lib/Support/Unix/Path.inc Thu Jul 28 23:42:39 2011
@@ -251,9 +251,12 @@
 
 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();
   }
 





More information about the llvm-commits mailing list