diff --git a/clang/test/VFS/relative-path-errors.c b/clang/test/VFS/relative-path-errors.c new file mode 100644 --- /dev/null +++ b/clang/test/VFS/relative-path-errors.c @@ -0,0 +1,8 @@ +// RUN: mkdir -p %t +// RUN: cd %t +// RUN: echo '{"roots": [],"version": 0}' > %t.yaml +// RUN: cp %s main.c +// RUN: not %clang_cc1 -ivfsoverlay %t.yaml main.c 2>&1 | FileCheck %s + +// CHECK: {{^}}main.c:8:1: error: +foobarbaz diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp --- a/llvm/lib/Support/VirtualFileSystem.cpp +++ b/llvm/lib/Support/VirtualFileSystem.cpp @@ -1202,7 +1202,7 @@ if (!Result) { EC = Result.getError(); if (shouldFallBackToExternalFS(EC)) - return ExternalFS->dir_begin(Path, EC); + return ExternalFS->dir_begin(Dir, EC); return {}; } @@ -1967,13 +1967,13 @@ ErrorOr Result = lookupPath(Path); if (!Result) { if (shouldFallBackToExternalFS(Result.getError())) - return ExternalFS->status(Path); + return ExternalFS->status(Path_); return Result.getError(); } ErrorOr S = status(Path, *Result); if (!S && shouldFallBackToExternalFS(S.getError(), Result->E)) - S = ExternalFS->status(Path); + S = ExternalFS->status(Path_); return S; } @@ -2013,7 +2013,7 @@ ErrorOr Result = lookupPath(Path); if (!Result) { if (shouldFallBackToExternalFS(Result.getError())) - return ExternalFS->openFileForRead(Path); + return ExternalFS->openFileForRead(Path_); return Result.getError(); } @@ -2026,7 +2026,7 @@ auto ExternalFile = ExternalFS->openFileForRead(ExtRedirect); if (!ExternalFile) { if (shouldFallBackToExternalFS(ExternalFile.getError(), Result->E)) - return ExternalFS->openFileForRead(Path); + return ExternalFS->openFileForRead(Path_); return ExternalFile; } @@ -2053,7 +2053,7 @@ ErrorOr Result = lookupPath(Path); if (!Result) { if (shouldFallBackToExternalFS(Result.getError())) - return ExternalFS->getRealPath(Path, Output); + return ExternalFS->getRealPath(Path_, Output); return Result.getError(); } @@ -2062,14 +2062,14 @@ if (auto ExtRedirect = Result->getExternalRedirect()) { auto P = ExternalFS->getRealPath(*ExtRedirect, Output); if (!P && shouldFallBackToExternalFS(P, Result->E)) { - return ExternalFS->getRealPath(Path, Output); + return ExternalFS->getRealPath(Path_, Output); } return P; } // If we found a DirectoryEntry, still fall back to ExternalFS if allowed, // because directories don't have a single external contents path. - return shouldUseExternalFS() ? ExternalFS->getRealPath(Path, Output) + return shouldUseExternalFS() ? ExternalFS->getRealPath(Path_, Output) : llvm::errc::invalid_argument; }