diff options
author | Sam McCall <sam.mccall@gmail.com> | 2018-09-14 12:47:38 +0000 |
---|---|---|
committer | Sam McCall <sam.mccall@gmail.com> | 2018-09-14 12:47:38 +0000 |
commit | 446fa15e649709fc8bde40ed422d1e4794ac9559 (patch) | |
tree | b1bd6c5cef32691bbaaefb4b863259c66c6a30ce /lib/Frontend/FrontendAction.cpp | |
parent | 344263148132b73d4440cdf8e806c24b8d017050 (diff) | |
download | clang-446fa15e649709fc8bde40ed422d1e4794ac9559.tar.gz |
[VFS] vfs::directory_iterator yields path and file type instead of full Status
Summary:
Most callers I can find are using only `getName()`. Type is used by the
recursive iterator.
Now we don't have to call stat() on every listed file (on most platforms).
Exceptions are e.g. Solaris where readdir() doesn't include type information.
On those platforms we'll still stat() - see D51918.
The result is significantly faster (stat() can be slow).
My motivation: this may allow us to improve clang IO on large TUs with long
include search paths. Caching readdir() results may allow us to skip many stat()
and open() operations on nonexistent files.
Reviewers: bkramer
Subscribers: fedor.sergeev, cfe-commits
Differential Revision: https://reviews.llvm.org/D51921
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342232 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/FrontendAction.cpp')
-rw-r--r-- | lib/Frontend/FrontendAction.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/Frontend/FrontendAction.cpp b/lib/Frontend/FrontendAction.cpp index 74550c4103..ddb522ae05 100644 --- a/lib/Frontend/FrontendAction.cpp +++ b/lib/Frontend/FrontendAction.cpp @@ -347,12 +347,12 @@ static std::error_code collectModuleHeaderIncludes( Dir != End && !EC; Dir.increment(EC)) { // Check whether this entry has an extension typically associated with // headers. - if (!llvm::StringSwitch<bool>(llvm::sys::path::extension(Dir->getName())) - .Cases(".h", ".H", ".hh", ".hpp", true) - .Default(false)) + if (!llvm::StringSwitch<bool>(llvm::sys::path::extension(Dir->path())) + .Cases(".h", ".H", ".hh", ".hpp", true) + .Default(false)) continue; - const FileEntry *Header = FileMgr.getFile(Dir->getName()); + const FileEntry *Header = FileMgr.getFile(Dir->path()); // FIXME: This shouldn't happen unless there is a file system race. Is // that worth diagnosing? if (!Header) @@ -365,7 +365,7 @@ static std::error_code collectModuleHeaderIncludes( // Compute the relative path from the directory to this file. SmallVector<StringRef, 16> Components; - auto PathIt = llvm::sys::path::rbegin(Dir->getName()); + auto PathIt = llvm::sys::path::rbegin(Dir->path()); for (int I = 0; I != Dir.level() + 1; ++I, ++PathIt) Components.push_back(*PathIt); SmallString<128> RelativeHeader(UmbrellaDir.NameAsWritten); @@ -696,10 +696,10 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, Dir != DirEnd && !EC; Dir.increment(EC)) { // Check whether this is an acceptable AST file. if (ASTReader::isAcceptableASTFile( - Dir->getName(), FileMgr, CI.getPCHContainerReader(), + Dir->path(), FileMgr, CI.getPCHContainerReader(), CI.getLangOpts(), CI.getTargetOpts(), CI.getPreprocessorOpts(), SpecificModuleCachePath)) { - PPOpts.ImplicitPCHInclude = Dir->getName(); + PPOpts.ImplicitPCHInclude = Dir->path(); Found = true; break; } |