aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/VirtualFileSystem.cpp
diff options
context:
space:
mode:
authorEllis Hoag <ellis.sparky.hoag@gmail.com>2024-05-07 13:55:44 -0700
committerGitHub <noreply@github.com>2024-05-07 13:55:44 -0700
commit2ad6917c4c524576405f2146424911fd9adb3528 (patch)
tree58478e2641839c5b0b6162fc81c411669a0900d4 /llvm/lib/Support/VirtualFileSystem.cpp
parenta70ad96b3cc5275246f7f007d1892bb867b75bc0 (diff)
downloadllvm-2ad6917c4c524576405f2146424911fd9adb3528.zip
llvm-2ad6917c4c524576405f2146424911fd9adb3528.tar.gz
llvm-2ad6917c4c524576405f2146424911fd9adb3528.tar.bz2
[modules] Accept equivalent module caches from different symlink (#90925)
Use `VFS.equivalent()`, which follows symlinks, to check if two module cache paths are equivalent. This prevents a PCH error when building from a different path that is a symlink of the original. ``` error: PCH was compiled with module cache path '/home/foo/blah/ModuleCache/2IBP1TNT8OR8D', but the path is currently '/data/users/foo/blah/ModuleCache/2IBP1TNT8OR8D' 1 error generated. ```
Diffstat (limited to 'llvm/lib/Support/VirtualFileSystem.cpp')
-rw-r--r--llvm/lib/Support/VirtualFileSystem.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp
index 152fcfe..54b9c38 100644
--- a/llvm/lib/Support/VirtualFileSystem.cpp
+++ b/llvm/lib/Support/VirtualFileSystem.cpp
@@ -151,6 +151,16 @@ bool FileSystem::exists(const Twine &Path) {
return Status && Status->exists();
}
+llvm::ErrorOr<bool> FileSystem::equivalent(const Twine &A, const Twine &B) {
+ auto StatusA = status(A);
+ if (!StatusA)
+ return StatusA.getError();
+ auto StatusB = status(B);
+ if (!StatusB)
+ return StatusB.getError();
+ return StatusA->equivalent(*StatusB);
+}
+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void FileSystem::dump() const { print(dbgs(), PrintType::RecursiveContents); }
#endif