Skip to content

Commit ef64a9d

Browse files
jansvoboda11mahesh-attarde
authored andcommitted
[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 b3808aa commit ef64a9d

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
@@ -8172,12 +8172,17 @@ void CodeGenModule::printPostfixForExternalizedDecl(llvm::raw_ostream &OS,
81728172

81738173
// Get the UniqueID for the file containing the decl.
81748174
llvm::sys::fs::UniqueID ID;
8175-
if (llvm::sys::fs::getUniqueID(PLoc.getFilename(), ID)) {
8175+
auto Status = FS->status(PLoc.getFilename());
8176+
if (!Status) {
81768177
PLoc = SM.getPresumedLoc(D->getLocation(), /*UseLineDirectives=*/false);
81778178
assert(PLoc.isValid() && "Source location is expected to be valid.");
8178-
if (auto EC = llvm::sys::fs::getUniqueID(PLoc.getFilename(), ID))
8179-
SM.getDiagnostics().Report(diag::err_cannot_open_file)
8180-
<< PLoc.getFilename() << EC.message();
8179+
Status = FS->status(PLoc.getFilename());
8180+
}
8181+
if (!Status) {
8182+
SM.getDiagnostics().Report(diag::err_cannot_open_file)
8183+
<< PLoc.getFilename() << Status.getError().message();
8184+
} else {
8185+
ID = Status->getUniqueID();
81818186
}
81828187
OS << llvm::format("%x", ID.getFile()) << llvm::format("%x", ID.getDevice())
81838188
<< "_" << llvm::utohexstr(Result.low(), /*LowerCase=*/true, /*Width=*/8);

0 commit comments

Comments
 (0)