[cfe-commits] r123150 - in /cfe/trunk/lib: Driver/Driver.cpp Driver/ToolChains.cpp Driver/Tools.cpp Frontend/CompilerInstance.cpp Lex/HeaderSearch.cpp

Michael J. Spencer bigcheesegs at gmail.com
Sun Jan 9 18:34:14 PST 2011


Author: mspencer
Date: Sun Jan  9 20:34:13 2011
New Revision: 123150

URL: http://llvm.org/viewvc/llvm-project?rev=123150&view=rev
Log:
Replace all uses of PathV1::exists with PathV2::fs::exists.

Modified:
    cfe/trunk/lib/Driver/Driver.cpp
    cfe/trunk/lib/Driver/ToolChains.cpp
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/lib/Frontend/CompilerInstance.cpp
    cfe/trunk/lib/Lex/HeaderSearch.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=123150&r1=123149&r2=123150&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Sun Jan  9 20:34:13 2011
@@ -1229,7 +1229,8 @@
   if (!PrefixDir.empty()) {
     llvm::sys::Path P(PrefixDir);
     P.appendComponent(Name);
-    if (P.exists())
+    bool Exists;
+    if (!llvm::sys::fs::exists(P.str(), Exists) && Exists)
       return P.str();
   }
 
@@ -1238,7 +1239,8 @@
          it = List.begin(), ie = List.end(); it != ie; ++it) {
     llvm::sys::Path P(*it);
     P.appendComponent(Name);
-    if (P.exists())
+    bool Exists;
+    if (!llvm::sys::fs::exists(P.str(), Exists) && Exists)
       return P.str();
   }
 
@@ -1252,7 +1254,9 @@
   if (!PrefixDir.empty()) {
     llvm::sys::Path P(PrefixDir);
     P.appendComponent(Name);
-    if (WantFile ? P.exists() : P.canExecute())
+    bool Exists;
+    if (WantFile ? !llvm::sys::fs::exists(P.str(), Exists) && Exists
+                 : P.canExecute())
       return P.str();
   }
 
@@ -1261,7 +1265,9 @@
          it = List.begin(), ie = List.end(); it != ie; ++it) {
     llvm::sys::Path P(*it);
     P.appendComponent(Name);
-    if (WantFile ? P.exists() : P.canExecute())
+    bool Exists;
+    if (WantFile ? !llvm::sys::fs::exists(P.str(), Exists) && Exists
+                 : P.canExecute())
       return P.str();
   }
 

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=123150&r1=123149&r2=123150&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Sun Jan  9 20:34:13 2011
@@ -23,6 +23,7 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/Path.h"
@@ -148,7 +149,8 @@
 
   // Try the next major version if that tool chain dir is invalid.
   std::string Tmp = "/usr/lib/gcc/" + ToolChainDir;
-  if (!llvm::sys::Path(Tmp).exists()) {
+  bool Exists;
+  if (llvm::sys::fs::exists(Tmp, Exists) || Exists) {
     std::string Next = "i686-apple-darwin";
     Next += llvm::utostr(DarwinVersion[0] + 1);
     Next += "/";
@@ -162,7 +164,7 @@
     //
     // FIXME: Drop dependency on gcc's tool chain.
     Tmp = "/usr/lib/gcc/" + Next;
-    if (llvm::sys::Path(Tmp).exists())
+    if (!llvm::sys::fs::exists(Tmp, Exists) && Exists)
       ToolChainDir = Next;
   }
 
@@ -307,19 +309,20 @@
   CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/" + ToolChainDir));
 
   Tmp = getDriver().Dir + "/../lib/gcc/" + ToolChainDir;
-  if (llvm::sys::Path(Tmp).exists())
+  bool Exists;
+  if (!llvm::sys::fs::exists(Tmp, Exists) && Exists)
     CmdArgs.push_back(Args.MakeArgString("-L" + Tmp));
   Tmp = getDriver().Dir + "/../lib/gcc";
-  if (llvm::sys::Path(Tmp).exists())
+  if (!llvm::sys::fs::exists(Tmp, Exists) && Exists)
     CmdArgs.push_back(Args.MakeArgString("-L" + Tmp));
   CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir));
   // Intentionally duplicated for (temporary) gcc bug compatibility.
   CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir));
   Tmp = getDriver().Dir + "/../lib/" + ToolChainDir;
-  if (llvm::sys::Path(Tmp).exists())
+  if (!llvm::sys::fs::exists(Tmp, Exists) && Exists)
     CmdArgs.push_back(Args.MakeArgString("-L" + Tmp));
   Tmp = getDriver().Dir + "/../lib";
-  if (llvm::sys::Path(Tmp).exists())
+  if (!llvm::sys::fs::exists(Tmp, Exists) && Exists)
     CmdArgs.push_back(Args.MakeArgString("-L" + Tmp));
   CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir +
                                        "/../../../" + ToolChainDir));
@@ -457,12 +460,14 @@
 
   if (ArchSpecificDir) {
     P.appendComponent(ArchSpecificDir);
-    if (P.exists())
+    bool Exists;
+    if (!llvm::sys::fs::exists(P.str(), Exists) && Exists)
       CmdArgs.push_back(Args.MakeArgString("-L" + P.str()));
     P.eraseComponent();
   }
 
-  if (P.exists())
+  bool Exists;
+  if (!llvm::sys::fs::exists(P.str(), Exists) && Exists)
     CmdArgs.push_back(Args.MakeArgString("-L" + P.str()));
 }
 
@@ -528,7 +533,8 @@
 
     // For now, allow missing resource libraries to support developers who may
     // not have compiler-rt checked out or integrated into their build.
-    if (P.exists())
+    bool Exists;
+    if (!llvm::sys::fs::exists(P.str(), Exists) && Exists)
       CmdArgs.push_back(Args.MakeArgString(P.str()));
   }
 }
@@ -622,16 +628,17 @@
     // explicitly if we can't see an obvious -lstdc++ candidate.
 
     // Check in the sysroot first.
+    bool Exists;
     if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
       llvm::sys::Path P(A->getValue(Args));
       P.appendComponent("usr");
       P.appendComponent("lib");
       P.appendComponent("libstdc++.dylib");
 
-      if (!P.exists()) {
+      if (llvm::sys::fs::exists(P.str(), Exists) || !Exists) {
         P.eraseComponent();
         P.appendComponent("libstdc++.6.dylib");
-        if (P.exists()) {
+        if (!llvm::sys::fs::exists(P.str(), Exists) && Exists) {
           CmdArgs.push_back(Args.MakeArgString(P.str()));
           return;
         }
@@ -639,8 +646,8 @@
     }
 
     // Otherwise, look in the root.
-    if (!llvm::sys::Path("/usr/lib/libstdc++.dylib").exists() &&
-        llvm::sys::Path("/usr/lib/libstdc++.6.dylib").exists()) {
+    if ((llvm::sys::fs::exists("/usr/lib/libstdc++.dylib", Exists) || !Exists)&&
+      (!llvm::sys::fs::exists("/usr/lib/libstdc++.6.dylib", Exists) && Exists)){
       CmdArgs.push_back("/usr/lib/libstdc++.6.dylib");
       return;
     }
@@ -666,7 +673,8 @@
   
   // For now, allow missing resource libraries to support developers who may
   // not have compiler-rt checked out or integrated into their build.
-  if (P.exists())
+  bool Exists;
+  if (!llvm::sys::fs::exists(P.str(), Exists) && Exists)
     CmdArgs.push_back(Args.MakeArgString(P.str()));
 }
 
@@ -1233,7 +1241,9 @@
 
 static bool HasMultilib(llvm::Triple::ArchType Arch, enum LinuxDistro Distro) {
   if (Arch == llvm::Triple::x86_64) {
-    if (Distro == Exherbo && !llvm::sys::Path("/usr/lib32/libc.so").exists())
+    bool Exists;
+    if (Distro == Exherbo &&
+        (llvm::sys::fs::exists("/usr/lib32/libc.so", Exists) || !Exists))
       return false;
 
     return true;
@@ -1287,7 +1297,8 @@
     return UnknownDistro;
   }
 
-  if (llvm::sys::Path("/etc/exherbo-release").exists())
+  bool Exists;
+  if (!llvm::sys::fs::exists("/etc/exherbo-release", Exists) && Exists)
     return Exherbo;
 
   return UnknownDistro;
@@ -1308,39 +1319,51 @@
 
   std::string Lib32 = "lib";
 
-  if (  llvm::sys::Path("/lib32").exists())
+  bool Exists;
+  if (!llvm::sys::fs::exists("/lib32", Exists) && Exists)
     Lib32 = "lib32";
 
   std::string Lib64 = "lib";
   llvm::sys::Path Lib64Path("/lib64");
-  if (Lib64Path.exists() && !Lib64Path.isSymLink())
+  if (!llvm::sys::fs::exists(Lib64Path.str(), Exists) && Exists &&
+      !Lib64Path.isSymLink())
     Lib64 = "lib64";
 
   std::string GccTriple = "";
   if (Arch == llvm::Triple::arm) {
-    if (llvm::sys::Path("/usr/lib/gcc/arm-linux-gnueabi").exists())
+    if (!llvm::sys::fs::exists("/usr/lib/gcc/arm-linux-gnueabi", Exists) &&
+        Exists)
       GccTriple = "arm-linux-gnueabi";
   } else if (Arch == llvm::Triple::x86_64) {
-    if (llvm::sys::Path("/usr/lib/gcc/x86_64-linux-gnu").exists())
+    if (!llvm::sys::fs::exists("/usr/lib/gcc/x86_64-linux-gnu", Exists) &&
+        Exists)
       GccTriple = "x86_64-linux-gnu";
-    else if (llvm::sys::Path("/usr/lib/gcc/x86_64-unknown-linux-gnu").exists())
+    else if (!llvm::sys::fs::exists("/usr/lib/gcc/x86_64-unknown-linux-gnu",
+             Exists) && Exists)
       GccTriple = "x86_64-unknown-linux-gnu";
-    else if (llvm::sys::Path("/usr/lib/gcc/x86_64-pc-linux-gnu").exists())
+    else if (!llvm::sys::fs::exists("/usr/lib/gcc/x86_64-pc-linux-gnu",
+             Exists) && Exists)
       GccTriple = "x86_64-pc-linux-gnu";
-    else if (llvm::sys::Path("/usr/lib/gcc/x86_64-redhat-linux").exists())
+    else if (!llvm::sys::fs::exists("/usr/lib/gcc/x86_64-redhat-linux",
+             Exists) && Exists)
       GccTriple = "x86_64-redhat-linux";
-    else if (llvm::sys::Path("/usr/lib64/gcc/x86_64-suse-linux").exists())
+    else if (!llvm::sys::fs::exists("/usr/lib64/gcc/x86_64-suse-linux",
+             Exists) && Exists)
       GccTriple = "x86_64-suse-linux";
   } else if (Arch == llvm::Triple::x86) {
-    if (llvm::sys::Path("/usr/lib/gcc/i686-linux-gnu").exists())
+    if (!llvm::sys::fs::exists("/usr/lib/gcc/i686-linux-gnu", Exists) && Exists)
       GccTriple = "i686-linux-gnu";
-    else if (llvm::sys::Path("/usr/lib/gcc/i686-pc-linux-gnu").exists())
+    else if (!llvm::sys::fs::exists("/usr/lib/gcc/i686-pc-linux-gnu", Exists) &&
+             Exists)
       GccTriple = "i686-pc-linux-gnu";
-    else if (llvm::sys::Path("/usr/lib/gcc/i486-linux-gnu").exists())
+    else if (!llvm::sys::fs::exists("/usr/lib/gcc/i486-linux-gnu", Exists) &&
+             Exists)
       GccTriple = "i486-linux-gnu";
-    else if (llvm::sys::Path("/usr/lib/gcc/i686-redhat-linux").exists())
+    else if (!llvm::sys::fs::exists("/usr/lib/gcc/i686-redhat-linux", Exists) &&
+             Exists)
       GccTriple = "i686-redhat-linux";
-    else if (llvm::sys::Path("/usr/lib/gcc/i586-suse-linux").exists())
+    else if (!llvm::sys::fs::exists("/usr/lib/gcc/i586-suse-linux", Exists) &&
+             Exists)
       GccTriple = "i586-suse-linux";
   }
 
@@ -1350,12 +1373,12 @@
   for (unsigned i = 0; i < sizeof(GccVersions)/sizeof(char*); ++i) {
     std::string Suffix = GccTriple + "/" + GccVersions[i];
     std::string t1 = "/usr/lib/gcc/" + Suffix;
-    if (llvm::sys::Path(t1 + "/crtbegin.o").exists()) {
+    if (!llvm::sys::fs::exists(t1 + "/crtbegin.o", Exists) && Exists) {
       Base = t1;
       break;
     }
     std::string t2 = "/usr/lib64/gcc/" + Suffix;
-    if (llvm::sys::Path(t2 + "/crtbegin.o").exists()) {
+    if (!llvm::sys::fs::exists(t2 + "/crtbegin.o", Exists) && Exists) {
       Base = t2;
       break;
     }
@@ -1376,7 +1399,7 @@
   }
 
   llvm::sys::Path LinkerPath(Base + "/../../../../" + GccTriple + "/bin/ld");
-  if (LinkerPath.exists())
+  if (!llvm::sys::fs::exists(LinkerPath.str(), Exists) && Exists)
     Linker = LinkerPath.str();
   else
     Linker = GetProgramPath("ld");

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=123150&r1=123149&r2=123150&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sun Jan  9 20:34:13 2011
@@ -25,6 +25,7 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/Host.h"
@@ -224,9 +225,10 @@
       bool FoundPTH = false;
       bool FoundPCH = false;
       llvm::sys::Path P(A->getValue(Args));
+      bool Exists;
       if (UsePCH) {
         P.appendSuffix("pch");
-        if (P.exists())
+        if (!llvm::sys::fs::exists(P.str(), Exists) && Exists)
           FoundPCH = true;
         else
           P.eraseSuffix();
@@ -234,7 +236,7 @@
 
       if (!FoundPCH) {
         P.appendSuffix("pth");
-        if (P.exists())
+        if (!llvm::sys::fs::exists(P.str(), Exists) && Exists)
           FoundPTH = true;
         else
           P.eraseSuffix();
@@ -242,7 +244,7 @@
 
       if (!FoundPCH && !FoundPTH) {
         P.appendSuffix("gch");
-        if (P.exists()) {
+        if (!llvm::sys::fs::exists(P.str(), Exists) && Exists) {
           FoundPCH = UsePCH;
           FoundPTH = !UsePCH;
         }

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=123150&r1=123149&r2=123150&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Sun Jan  9 20:34:13 2011
@@ -28,6 +28,7 @@
 #include "clang/Serialization/ASTReader.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "llvm/LLVMContext.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/ADT/Statistic.h"
@@ -433,7 +434,8 @@
     llvm::sys::Path OutPath(OutFile);
     // Only create the temporary if we can actually write to OutPath, otherwise
     // we want to fail early.
-    if (!OutPath.exists() ||
+    bool Exists;
+    if ((llvm::sys::fs::exists(OutPath.str(), Exists) || !Exists) ||
         (OutPath.isRegularFile() && OutPath.canWrite())) {
       // Create a temporary file.
       llvm::sys::Path TempPath(OutFile);

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=123150&r1=123149&r2=123150&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Sun Jan  9 20:34:13 2011
@@ -15,6 +15,7 @@
 #include "clang/Lex/HeaderMap.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/IdentifierTable.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/ADT/SmallString.h"
 #include <cstdio>
@@ -170,8 +171,8 @@
 
     // If the framework dir doesn't exist, we fail.
     // FIXME: It's probably more efficient to query this with FileMgr.getDir.
-    if (!llvm::sys::Path(std::string(FrameworkName.begin(),
-                                     FrameworkName.end())).exists())
+    bool Exists;
+    if (llvm::sys::fs::exists(FrameworkName.str(), Exists) || !Exists)
       return 0;
 
     // Otherwise, if it does, remember that this is the right direntry for this





More information about the cfe-commits mailing list