diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2025-09-26 14:54:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-09-26 14:54:03 -0700 |
commit | 7b3d28573c1c3ae74fc829d659a6a99c02d961f9 (patch) | |
tree | a309a19f14c8e71016e093cfb113517cba4a47db /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 34ebdaf73287e4f0fd9e897d01060071dbc42e99 (diff) | |
download | llvm-7b3d28573c1c3ae74fc829d659a6a99c02d961f9.zip llvm-7b3d28573c1c3ae74fc829d659a6a99c02d961f9.tar.gz llvm-7b3d28573c1c3ae74fc829d659a6a99c02d961f9.tar.bz2 |
[clang] Use the VFS to get the unique file ID (#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.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 875f06b..f6f7f22 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -8172,12 +8172,17 @@ void CodeGenModule::printPostfixForExternalizedDecl(llvm::raw_ostream &OS, // Get the UniqueID for the file containing the decl. llvm::sys::fs::UniqueID ID; - if (llvm::sys::fs::getUniqueID(PLoc.getFilename(), ID)) { + auto Status = FS->status(PLoc.getFilename()); + if (!Status) { PLoc = SM.getPresumedLoc(D->getLocation(), /*UseLineDirectives=*/false); assert(PLoc.isValid() && "Source location is expected to be valid."); - if (auto EC = llvm::sys::fs::getUniqueID(PLoc.getFilename(), ID)) - SM.getDiagnostics().Report(diag::err_cannot_open_file) - << PLoc.getFilename() << EC.message(); + Status = FS->status(PLoc.getFilename()); + } + if (!Status) { + SM.getDiagnostics().Report(diag::err_cannot_open_file) + << PLoc.getFilename() << Status.getError().message(); + } else { + ID = Status->getUniqueID(); } OS << llvm::format("%x", ID.getFile()) << llvm::format("%x", ID.getDevice()) << "_" << llvm::utohexstr(Result.low(), /*LowerCase=*/true, /*Width=*/8); |