Skip to content

Commit bde84e9

Browse files
committed
[next] Fix build and tests after 5a8a7ee
Handle exists() method that is virtual on the branch. rdar://124694281 (cherry picked from commit 1f368e9)
1 parent e38cfad commit bde84e9

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

llvm/lib/Support/VirtualFileSystem.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2462,27 +2462,26 @@ ErrorOr<Status> RedirectingFileSystem::status(const Twine &OriginalPath) {
24622462
}
24632463

24642464
bool RedirectingFileSystem::exists(const Twine &OriginalPath) {
2465-
SmallString<256> CanonicalPath;
2466-
OriginalPath.toVector(CanonicalPath);
2465+
SmallString<256> Path;
2466+
OriginalPath.toVector(Path);
24672467

2468-
if (makeCanonical(CanonicalPath))
2468+
if (makeAbsolute(Path))
24692469
return false;
24702470

24712471
if (Redirection == RedirectKind::Fallback) {
24722472
// Attempt to find the original file first, only falling back to the
24732473
// mapped file if that fails.
2474-
if (ExternalFS->exists(CanonicalPath))
2474+
if (ExternalFS->exists(Path))
24752475
return true;
24762476
}
24772477

2478-
ErrorOr<RedirectingFileSystem::LookupResult> Result =
2479-
lookupPath(CanonicalPath);
2478+
ErrorOr<RedirectingFileSystem::LookupResult> Result = lookupPath(Path);
24802479
if (!Result) {
24812480
// Was not able to map file, fallthrough to using the original path if
24822481
// that was the specified redirection type.
24832482
if (Redirection == RedirectKind::Fallthrough &&
24842483
isFileNotFound(Result.getError()))
2485-
return ExternalFS->exists(CanonicalPath);
2484+
return ExternalFS->exists(Path);
24862485
return false;
24872486
}
24882487

@@ -2492,18 +2491,18 @@ bool RedirectingFileSystem::exists(const Twine &OriginalPath) {
24922491
return true;
24932492
}
24942493

2495-
SmallString<256> CanonicalRemappedPath((*ExtRedirect).str());
2496-
if (makeCanonical(CanonicalRemappedPath))
2494+
SmallString<256> RemappedPath((*ExtRedirect).str());
2495+
if (makeAbsolute(RemappedPath))
24972496
return false;
24982497

2499-
if (ExternalFS->exists(CanonicalRemappedPath))
2498+
if (ExternalFS->exists(RemappedPath))
25002499
return true;
25012500

25022501
if (Redirection == RedirectKind::Fallthrough) {
25032502
// Mapped the file but it wasn't found in the underlying filesystem,
25042503
// fallthrough to using the original path if that was the specified
25052504
// redirection type.
2506-
return ExternalFS->exists(CanonicalPath);
2505+
return ExternalFS->exists(Path);
25072506
}
25082507

25092508
return false;

llvm/unittests/Support/VirtualFileSystemTest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3543,6 +3543,11 @@ TEST(RedirectingFileSystemTest, ExternalPaths) {
35433543
SeenPaths.push_back(Dir.str());
35443544
return ProxyFileSystem::dir_begin(Dir, EC);
35453545
}
3546+
3547+
bool exists(const Twine &Path) override {
3548+
SeenPaths.push_back(Path.str());
3549+
return ProxyFileSystem::exists(Path);
3550+
}
35463551
};
35473552

35483553
std::error_code EC;

0 commit comments

Comments
 (0)