r270226 - Eliminate unnecessary file access checks in Clang driver on Windows

Adrian McCarthy via cfe-commits cfe-commits at lists.llvm.org
Fri May 20 08:46:23 PDT 2016


Author: amccarth
Date: Fri May 20 10:46:23 2016
New Revision: 270226

URL: http://llvm.org/viewvc/llvm-project?rev=270226&view=rev
Log:
Eliminate unnecessary file access checks in Clang driver on Windows

Differential Revision: http://reviews.llvm.org/D20454

Modified:
    cfe/trunk/lib/Driver/MSVCToolChain.cpp

Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MSVCToolChain.cpp?rev=270226&r1=270225&r2=270226&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/MSVCToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/MSVCToolChain.cpp Fri May 20 10:46:23 2016
@@ -408,7 +408,10 @@ bool MSVCToolChain::getVisualStudioBinar
 
         SmallString<128> FilePath(PathSegment);
         llvm::sys::path::append(FilePath, "cl.exe");
-        if (llvm::sys::fs::can_execute(FilePath.c_str()) &&
+        // Checking if cl.exe exists is a small optimization over calling
+        // can_execute, which really only checks for existence but will also do
+        // extra checks for cl.exe.exe.  These add up when walking a long path.
+        if (llvm::sys::fs::exists(FilePath.c_str()) &&
             !llvm::sys::fs::equivalent(FilePath.c_str(), clangProgramPath)) {
           // If we found it on the PATH, use it exactly as is with no
           // modifications.




More information about the cfe-commits mailing list