diff options
author | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2016-03-30 23:54:00 +0000 |
---|---|---|
committer | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2016-03-30 23:54:00 +0000 |
commit | d712b34167624ce3ca2f96dcef8d5cd5115d0ae9 (patch) | |
tree | de3f6fd90c8107bcc0ec0dc98328a80cdbfc0169 /clang/lib/Basic/VirtualFileSystem.cpp | |
parent | 19b648eae3bb85e30d08665305fb506cbff7626a (diff) | |
download | llvm-d712b34167624ce3ca2f96dcef8d5cd5115d0ae9.zip llvm-d712b34167624ce3ca2f96dcef8d5cd5115d0ae9.tar.gz llvm-d712b34167624ce3ca2f96dcef8d5cd5115d0ae9.tar.bz2 |
[VFS] Handle empty entries in directory traversal
The VFS YAML files contain empty directory entries to describe that it's
returning from a subdirectory before describing new files in the parent.
In the future, we should properly sort and write YAML files avoiding
such empty dirs and mitigate the extra recurson cost. However, since
this is used by previous existing YAMLs, make the traversal work in
their presence.
rdar://problem/24499339
llvm-svn: 264970
Diffstat (limited to 'clang/lib/Basic/VirtualFileSystem.cpp')
-rw-r--r-- | clang/lib/Basic/VirtualFileSystem.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp index 325e5eb..a44111a 100644 --- a/clang/lib/Basic/VirtualFileSystem.cpp +++ b/clang/lib/Basic/VirtualFileSystem.cpp @@ -1358,16 +1358,21 @@ RedirectingFileSystem::lookupPath(sys::path::const_iterator Start, ++Start; #endif - if (CaseSensitive ? !Start->equals(From->getName()) - : !Start->equals_lower(From->getName())) - // failure to match - return make_error_code(llvm::errc::no_such_file_or_directory); + StringRef FromName = From->getName(); - ++Start; + // Forward the search to the next component in case this is an empty one. + if (!FromName.empty()) { + if (CaseSensitive ? !Start->equals(FromName) + : !Start->equals_lower(FromName)) + // failure to match + return make_error_code(llvm::errc::no_such_file_or_directory); - if (Start == End) { - // Match! - return From; + ++Start; + + if (Start == End) { + // Match! + return From; + } } auto *DE = dyn_cast<RedirectingDirectoryEntry>(From); |