[clang-tools-extra] r315378 - Support: Have directory_iterator::status() return FindFirstFileEx/FindNextFile results on Windows.
Peter Collingbourne via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 10 15:19:46 PDT 2017
Author: pcc
Date: Tue Oct 10 15:19:46 2017
New Revision: 315378
URL: http://llvm.org/viewvc/llvm-project?rev=315378&view=rev
Log:
Support: Have directory_iterator::status() return FindFirstFileEx/FindNextFile results on Windows.
This allows clients to avoid an unnecessary fs::status() call on each
directory entry. Because the information returned by FindFirstFileEx
is a subset of the information returned by a regular status() call,
I needed to extract a base class from file_status that contains only
that information.
On my machine, this reduces the time required to enumerate a ThinLTO
cache directory containing 520k files from almost 4 minutes to less
than 2 seconds.
Differential Revision: https://reviews.llvm.org/D38716
Modified:
clang-tools-extra/trunk/modularize/CoverageChecker.cpp
clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp
Modified: clang-tools-extra/trunk/modularize/CoverageChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/CoverageChecker.cpp?rev=315378&r1=315377&r2=315378&view=diff
==============================================================================
--- clang-tools-extra/trunk/modularize/CoverageChecker.cpp (original)
+++ clang-tools-extra/trunk/modularize/CoverageChecker.cpp Tue Oct 10 15:19:46 2017
@@ -242,14 +242,15 @@ bool CoverageChecker::collectUmbrellaHea
Directory = ".";
// Walk the directory.
std::error_code EC;
- sys::fs::file_status Status;
for (sys::fs::directory_iterator I(Directory.str(), EC), E; I != E;
I.increment(EC)) {
if (EC)
return false;
std::string File(I->path());
- I->status(Status);
- sys::fs::file_type Type = Status.type();
+ llvm::ErrorOr<sys::fs::basic_file_status> Status = I->status();
+ if (!Status)
+ return false;
+ sys::fs::file_type Type = Status->type();
// If the file is a directory, ignore the name and recurse.
if (Type == sys::fs::file_type::directory_file) {
if (!collectUmbrellaHeaders(File))
@@ -363,7 +364,6 @@ bool CoverageChecker::collectFileSystemH
// Recursively walk the directory tree.
std::error_code EC;
- sys::fs::file_status Status;
int Count = 0;
for (sys::fs::recursive_directory_iterator I(Directory.str(), EC), E; I != E;
I.increment(EC)) {
@@ -371,8 +371,10 @@ bool CoverageChecker::collectFileSystemH
return false;
//std::string file(I->path());
StringRef file(I->path());
- I->status(Status);
- sys::fs::file_type type = Status.type();
+ llvm::ErrorOr<sys::fs::basic_file_status> Status = I->status();
+ if (!Status)
+ return false;
+ sys::fs::file_type type = Status->type();
// If the file is a directory, ignore the name (but still recurses).
if (type == sys::fs::file_type::directory_file)
continue;
Modified: clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp?rev=315378&r1=315377&r2=315378&view=diff
==============================================================================
--- clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp (original)
+++ clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp Tue Oct 10 15:19:46 2017
@@ -399,14 +399,15 @@ bool ModularizeUtilities::collectUmbrell
SmallString<256> Directory(UmbrellaDirName);
// Walk the directory.
std::error_code EC;
- llvm::sys::fs::file_status Status;
for (llvm::sys::fs::directory_iterator I(Directory.str(), EC), E; I != E;
I.increment(EC)) {
if (EC)
return false;
std::string File(I->path());
- I->status(Status);
- llvm::sys::fs::file_type Type = Status.type();
+ llvm::ErrorOr<llvm::sys::fs::basic_file_status> Status = I->status();
+ if (!Status)
+ return false;
+ llvm::sys::fs::file_type Type = Status->type();
// If the file is a directory, ignore the name and recurse.
if (Type == llvm::sys::fs::file_type::directory_file) {
if (!collectUmbrellaHeaders(File, Dependents))
More information about the cfe-commits
mailing list