r217614 - Use the simpler version of llvm::sys::fs::exists.

Rafael Espindola rafael.espindola at gmail.com
Thu Sep 11 11:10:13 PDT 2014


Author: rafael
Date: Thu Sep 11 13:10:13 2014
New Revision: 217614

URL: http://llvm.org/viewvc/llvm-project?rev=217614&view=rev
Log:
Use the simpler version of llvm::sys::fs::exists.

In all these cases it looks like the intention was to handle error in a similar
way to the file not existing.

Modified:
    cfe/trunk/lib/ARCMigrate/FileRemapper.cpp
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/tools/arcmt-test/arcmt-test.cpp
    cfe/trunk/tools/driver/driver.cpp
    cfe/trunk/tools/libclang/ARCMigrate.cpp

Modified: cfe/trunk/lib/ARCMigrate/FileRemapper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/FileRemapper.cpp?rev=217614&r1=217613&r2=217614&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/FileRemapper.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/FileRemapper.cpp Thu Sep 11 13:10:13 2014
@@ -58,9 +58,7 @@ bool FileRemapper::initFromFile(StringRe
   assert(FromToMappings.empty() &&
          "initFromDisk should be called before any remap calls");
   std::string infoFile = filePath;
-  bool fileExists = false;
-  llvm::sys::fs::exists(infoFile, fileExists);
-  if (!fileExists)
+  if (!llvm::sys::fs::exists(infoFile))
     return false;
 
   std::vector<std::pair<const FileEntry *, const FileEntry *> > pairs;
@@ -173,9 +171,7 @@ bool FileRemapper::overwriteOriginal(Dia
          I = FromToMappings.begin(), E = FromToMappings.end(); I != E; ++I) {
     const FileEntry *origFE = I->first;
     assert(I->second.is<llvm::MemoryBuffer *>());
-    bool fileExists = false;
-    fs::exists(origFE->getName(), fileExists);
-    if (!fileExists)
+    if (!fs::exists(origFE->getName()))
       return report(StringRef("File does not exist: ") + origFE->getName(),
                     Diag);
 

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=217614&r1=217613&r2=217614&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Sep 11 13:10:13 2014
@@ -7626,12 +7626,9 @@ void dragonfly::Link::ConstructJob(Compi
                                    const InputInfoList &Inputs,
                                    const ArgList &Args,
                                    const char *LinkingOutput) const {
-  bool UseGCC47 = false;
   const Driver &D = getToolChain().getDriver();
   ArgStringList CmdArgs;
-
-  if (llvm::sys::fs::exists("/usr/lib/gcc47", UseGCC47))
-    UseGCC47 = false;
+  bool UseGCC47 = llvm::sys::fs::exists("/usr/lib/gcc47");
 
   if (!D.SysRoot.empty())
     CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));

Modified: cfe/trunk/tools/arcmt-test/arcmt-test.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/arcmt-test/arcmt-test.cpp?rev=217614&r1=217613&r2=217614&view=diff
==============================================================================
--- cfe/trunk/tools/arcmt-test/arcmt-test.cpp (original)
+++ cfe/trunk/tools/arcmt-test/arcmt-test.cpp Thu Sep 11 13:10:13 2014
@@ -269,14 +269,11 @@ static bool verifyTransformedFiles(Array
       return true;
     }
 
-    bool exists = false;
-    sys::fs::exists(It->second, exists);
-    if (!exists) {
+    if (!sys::fs::exists(It->second)) {
       errs() << "error: '" << It->second << "' does not exist\n";
       return true;
     }
-    sys::fs::exists(inputResultFname, exists);
-    if (!exists) {
+    if (!sys::fs::exists(inputResultFname)) {
       errs() << "error: '" << inputResultFname << "' does not exist\n";
       return true;
     }

Modified: cfe/trunk/tools/driver/driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=217614&r1=217613&r2=217614&view=diff
==============================================================================
--- cfe/trunk/tools/driver/driver.cpp (original)
+++ cfe/trunk/tools/driver/driver.cpp Thu Sep 11 13:10:13 2014
@@ -358,8 +358,7 @@ static void SetInstallDir(SmallVectorImp
   }
   llvm::sys::fs::make_absolute(InstalledPath);
   InstalledPath = llvm::sys::path::parent_path(InstalledPath);
-  bool exists;
-  if (!llvm::sys::fs::exists(InstalledPath.str(), exists) && exists)
+  if (llvm::sys::fs::exists(InstalledPath.c_str()))
     TheDriver.setInstalledDir(InstalledPath);
 }
 

Modified: cfe/trunk/tools/libclang/ARCMigrate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/ARCMigrate.cpp?rev=217614&r1=217613&r2=217614&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/ARCMigrate.cpp (original)
+++ cfe/trunk/tools/libclang/ARCMigrate.cpp Thu Sep 11 13:10:13 2014
@@ -47,9 +47,7 @@ CXRemapping clang_getRemappings(const ch
     return nullptr;
   }
 
-  bool exists = false;
-  llvm::sys::fs::exists(migrate_dir_path, exists);
-  if (!exists) {
+  if (!llvm::sys::fs::exists(migrate_dir_path)) {
     if (Logging) {
       llvm::errs() << "Error by clang_getRemappings(\"" << migrate_dir_path
                    << "\")\n";





More information about the cfe-commits mailing list