Skip to content

Commit 08b0356

Browse files
committed
[clang] Use the VFS to get the unique file ID (llvm#160936)
This PR uses the VFS to get the unique file ID when printing externalized decls in CUDA instead of going straight to the real file system. This matches the behavior of other input files of the compiler.
1 parent 6a59f0f commit 08b0356

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8116,12 +8116,17 @@ void CodeGenModule::printPostfixForExternalizedDecl(llvm::raw_ostream &OS,
81168116

81178117
// Get the UniqueID for the file containing the decl.
81188118
llvm::sys::fs::UniqueID ID;
8119-
if (llvm::sys::fs::getUniqueID(PLoc.getFilename(), ID)) {
8119+
auto Status = FS->status(PLoc.getFilename());
8120+
if (!Status) {
81208121
PLoc = SM.getPresumedLoc(D->getLocation(), /*UseLineDirectives=*/false);
81218122
assert(PLoc.isValid() && "Source location is expected to be valid.");
8122-
if (auto EC = llvm::sys::fs::getUniqueID(PLoc.getFilename(), ID))
8123-
SM.getDiagnostics().Report(diag::err_cannot_open_file)
8124-
<< PLoc.getFilename() << EC.message();
8123+
Status = FS->status(PLoc.getFilename());
8124+
}
8125+
if (!Status) {
8126+
SM.getDiagnostics().Report(diag::err_cannot_open_file)
8127+
<< PLoc.getFilename() << Status.getError().message();
8128+
} else {
8129+
ID = Status->getUniqueID();
81258130
}
81268131
OS << llvm::format("%x", ID.getFile()) << llvm::format("%x", ID.getDevice())
81278132
<< "_" << llvm::utohexstr(Result.low(), /*LowerCase=*/true, /*Width=*/8);

0 commit comments

Comments
 (0)