]> granicus.if.org Git - clang/commitdiff
Fixes a fix to finding the current directory:
authorManuel Klimek <klimek@google.com>
Mon, 9 Apr 2012 18:08:23 +0000 (18:08 +0000)
committerManuel Klimek <klimek@google.com>
Mon, 9 Apr 2012 18:08:23 +0000 (18:08 +0000)
We currently want to look whether PWD is available - if PWD is available it will
get us the non-resolved current path, while fs::current_path will resolve
symlinks. The long term fix is to not rely on that behavior any more.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154330 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Tooling/Tooling.cpp

index 4fa98aa2bfee90a0e69dab61bfd5f0770aa76ea9..fa2374f5e30def73a3d42e1aa0e51f6e769d8e21 100644 (file)
@@ -237,7 +237,10 @@ ClangTool::ClangTool(const CompilationDatabase &Compilations,
                      ArrayRef<std::string> SourcePaths)
     : Files((FileSystemOptions())) {
   llvm::SmallString<1024> BaseDirectory;
-  llvm::sys::fs::current_path(BaseDirectory);
+  if (const char *PWD = ::getenv("PWD"))
+    BaseDirectory = PWD;
+  else
+    llvm::sys::fs::current_path(BaseDirectory);
   for (unsigned I = 0, E = SourcePaths.size(); I != E; ++I) {
     llvm::SmallString<1024> File(getAbsolutePath(
         SourcePaths[I], BaseDirectory));