aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/modularize
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2017-10-10 22:19:46 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2017-10-10 22:19:46 +0000
commit0dfdb44797fa2ce4273e38f13403b62a5ce0a9b0 (patch)
tree7b4289f7eca8c5267e89a0a1fad53657e56dfe69 /clang-tools-extra/modularize
parentae5e9ed422be46d63384b7a9efdf925c4507994f (diff)
downloadllvm-0dfdb44797fa2ce4273e38f13403b62a5ce0a9b0.zip
llvm-0dfdb44797fa2ce4273e38f13403b62a5ce0a9b0.tar.gz
llvm-0dfdb44797fa2ce4273e38f13403b62a5ce0a9b0.tar.bz2
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 llvm-svn: 315378
Diffstat (limited to 'clang-tools-extra/modularize')
-rw-r--r--clang-tools-extra/modularize/CoverageChecker.cpp14
-rw-r--r--clang-tools-extra/modularize/ModularizeUtilities.cpp7
2 files changed, 12 insertions, 9 deletions
diff --git a/clang-tools-extra/modularize/CoverageChecker.cpp b/clang-tools-extra/modularize/CoverageChecker.cpp
index 510d062..3687872 100644
--- a/clang-tools-extra/modularize/CoverageChecker.cpp
+++ b/clang-tools-extra/modularize/CoverageChecker.cpp
@@ -242,14 +242,15 @@ bool CoverageChecker::collectUmbrellaHeaders(StringRef UmbrellaDirName) {
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::collectFileSystemHeaders(StringRef IncludePath) {
// 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::collectFileSystemHeaders(StringRef IncludePath) {
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;
diff --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp b/clang-tools-extra/modularize/ModularizeUtilities.cpp
index 874742d..85768d5 100644
--- a/clang-tools-extra/modularize/ModularizeUtilities.cpp
+++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp
@@ -399,14 +399,15 @@ bool ModularizeUtilities::collectUmbrellaHeaders(StringRef UmbrellaDirName,
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))