[clang] fix: replace report_fatal_error with Diags and exit (PR #147959)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 16 04:35:04 PDT 2025


================
@@ -30,11 +30,16 @@ SanitizerSpecialCaseList::create(const std::vector<std::string> &Paths,
 
 std::unique_ptr<SanitizerSpecialCaseList>
 SanitizerSpecialCaseList::createOrDie(const std::vector<std::string> &Paths,
-                                      llvm::vfs::FileSystem &VFS) {
+                                      llvm::vfs::FileSystem &VFS,
+                                      DiagnosticsEngine &Diags) {
   std::string Error;
   if (auto SSCL = create(Paths, VFS, Error))
     return SSCL;
-  llvm::report_fatal_error(StringRef(Error));
+  unsigned DiagID = Diags.getCustomDiagID(clang::DiagnosticsEngine::Error,
+                                          "failed to load NoSanitize file: %0");
----------------
AaronBallman wrote:

This shouldn't be a custom diagnostic; I would imagine this would be a driver diagnostic. But we can't emit driver diagnostics from Basic.

I think we need a bit wider of an approach where `createOrDie` is `create` which the caller has to respond to if it returns an empty `unique_ptr` so that the driver eventually is what emits the diagnostic.

CC @MaskRay for more opinions

https://github.com/llvm/llvm-project/pull/147959


More information about the cfe-commits mailing list