Skip to content

Commit 62405d9

Browse files
vgvassilevdevajithvs
authored andcommitted
Keep into account if files were virtual.
In some cases we do not have files on disk. They are only available in the FileManager as virtual files and the SourceManager overrides their content.
1 parent ed06991 commit 62405d9

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

clang/lib/AST/ASTImporter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9906,7 +9906,7 @@ Expected<FileID> ASTImporter::Import(FileID FromID, bool IsBuiltin) {
99069906
// FIXME: We want to re-use the existing MemoryBuffer!
99079907
std::optional<llvm::MemoryBufferRef> FromBuf =
99089908
Cache->getBufferOrNone(FromContext.getDiagnostics(),
9909-
FromSM.getFileManager(), SourceLocation{});
9909+
FromFileManager, SourceLocation{});
99109910
if (!FromBuf)
99119911
return llvm::make_error<ASTImportError>(ASTImportError::Unknown);
99129912

clang/lib/Frontend/VerifyDiagnosticConsumer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,11 @@ static bool ParseDirective(StringRef S, ExpectedData *ED, SourceManager &SM,
543543
OptionalFileEntryRef File =
544544
PP->LookupFile(Pos, Filename, false, nullptr, nullptr, nullptr,
545545
nullptr, nullptr, nullptr, nullptr, nullptr);
546+
547+
// Check if the file was virtual
548+
if (!File)
549+
File = SM.getFileManager().getOptionalFileRef(Filename);
550+
546551
if (!File) {
547552
Diags.Report(Pos.getLocWithOffset(PH.C - PH.Begin),
548553
diag::err_verify_missing_file)

0 commit comments

Comments
 (0)