Skip to content

Commit 1f368e9

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

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
@@ -2461,27 +2461,26 @@ ErrorOr<Status> RedirectingFileSystem::status(const Twine &OriginalPath) {
24612461
}
24622462

24632463
bool RedirectingFileSystem::exists(const Twine &OriginalPath) {
2464-
SmallString<256> CanonicalPath;
2465-
OriginalPath.toVector(CanonicalPath);
2464+
SmallString<256> Path;
2465+
OriginalPath.toVector(Path);
24662466

2467-
if (makeCanonical(CanonicalPath))
2467+
if (makeAbsolute(Path))
24682468
return false;
24692469

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

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

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

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

2498-
if (ExternalFS->exists(CanonicalRemappedPath))
2497+
if (ExternalFS->exists(RemappedPath))
24992498
return true;
25002499

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

25082507
return false;

llvm/unittests/Support/VirtualFileSystemTest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3525,6 +3525,11 @@ TEST(RedirectingFileSystemTest, ExternalPaths) {
35253525
SeenPaths.push_back(Dir.str());
35263526
return ProxyFileSystem::dir_begin(Dir, EC);
35273527
}
3528+
3529+
bool exists(const Twine &Path) override {
3530+
SeenPaths.push_back(Path.str());
3531+
return ProxyFileSystem::exists(Path);
3532+
}
35283533
};
35293534

35303535
std::error_code EC;

0 commit comments

Comments
 (0)