-
Notifications
You must be signed in to change notification settings - Fork 14.5k
fix: replace report_fatal_error with Diags and exit #147959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@llvm/pr-subscribers-clang-driver @llvm/pr-subscribers-clang Author: woruyu (woruyu) ChangesSummary Full diff: https://github.com/llvm/llvm-project/pull/147959.diff 3 Files Affected:
diff --git a/clang/include/clang/Basic/SanitizerSpecialCaseList.h b/clang/include/clang/Basic/SanitizerSpecialCaseList.h
index cf7485909e409..72cdcf7c467f0 100644
--- a/clang/include/clang/Basic/SanitizerSpecialCaseList.h
+++ b/clang/include/clang/Basic/SanitizerSpecialCaseList.h
@@ -14,6 +14,7 @@
#ifndef LLVM_CLANG_BASIC_SANITIZERSPECIALCASELIST_H
#define LLVM_CLANG_BASIC_SANITIZERSPECIALCASELIST_H
+#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/Sanitizers.h"
#include "llvm/ADT/StringRef.h"
@@ -37,8 +38,8 @@ class SanitizerSpecialCaseList : public llvm::SpecialCaseList {
std::string &Error);
static std::unique_ptr<SanitizerSpecialCaseList>
- createOrDie(const std::vector<std::string> &Paths,
- llvm::vfs::FileSystem &VFS);
+ createOrDie(const std::vector<std::string> &Paths, llvm::vfs::FileSystem &VFS,
+ DiagnosticsEngine &Diags);
// Query ignorelisted entries if any bit in Mask matches the entry's section.
bool inSection(SanitizerMask Mask, StringRef Prefix, StringRef Query,
diff --git a/clang/lib/Basic/NoSanitizeList.cpp b/clang/lib/Basic/NoSanitizeList.cpp
index 96f79fb2a2a29..1ae304fbd2132 100644
--- a/clang/lib/Basic/NoSanitizeList.cpp
+++ b/clang/lib/Basic/NoSanitizeList.cpp
@@ -22,7 +22,8 @@ using namespace clang;
NoSanitizeList::NoSanitizeList(const std::vector<std::string> &NoSanitizePaths,
SourceManager &SM)
: SSCL(SanitizerSpecialCaseList::createOrDie(
- NoSanitizePaths, SM.getFileManager().getVirtualFileSystem())),
+ NoSanitizePaths, SM.getFileManager().getVirtualFileSystem(),
+ SM.getDiagnostics())),
SM(SM) {}
NoSanitizeList::~NoSanitizeList() = default;
diff --git a/clang/lib/Basic/SanitizerSpecialCaseList.cpp b/clang/lib/Basic/SanitizerSpecialCaseList.cpp
index f7bc1d5545d75..51a09b341f495 100644
--- a/clang/lib/Basic/SanitizerSpecialCaseList.cpp
+++ b/clang/lib/Basic/SanitizerSpecialCaseList.cpp
@@ -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");
+
+ Diags.Report(DiagID) << Error;
+ exit(1);
}
void SanitizerSpecialCaseList::createSanitizerSections() {
|
@hstk30-hw This patch is now ready for review. |
Need a test case at least. |
Done! |
@shafik Take a look, pls. |
816fe1e
to
a4236f9
Compare
a4236f9
to
4920812
Compare
Hi,@hstk30-hw, @shafik, @AaronBallman just wanted to check if there’s anything further needed from my side for this patch. I’d be happy to help clarify or adjust anything. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, sorry for the delayed review! I had a comment several days ago but forgot to hit Submit. :-/
unsigned DiagID = Diags.getCustomDiagID(clang::DiagnosticsEngine::Error, | ||
"failed to load NoSanitize file: %0"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MaskRay Do you have any thoughts on this approach? Would appreciate your input.
Summary
This PR resolves #147187