Skip to content

Commit 479ae4a

Browse files
authored
Revert "fix: replace report_fatal_error with Diags and exit" (#150662)
Reverts #147959
1 parent da30197 commit 479ae4a

File tree

14 files changed

+41
-81
lines changed

14 files changed

+41
-81
lines changed

clang/include/clang/AST/ASTContext.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,6 @@ class ASTContext : public RefCountedBase<ASTContext> {
634634
void setRelocationInfoForCXXRecord(const CXXRecordDecl *,
635635
CXXRecordDeclRelocationInfo);
636636

637-
void initSanitizers(const LangOptions &LangOpts, SourceManager &SM);
638-
639637
/// Examines a given type, and returns whether the type itself
640638
/// is address discriminated, or any transitively embedded types
641639
/// contain data that is address discriminated. This includes

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,13 @@ def err_drv_invalid_argument_to_option : Error<
252252
def err_drv_missing_sanitizer_ignorelist : Error<
253253
"missing sanitizer ignorelist: '%0'">;
254254
def err_drv_malformed_sanitizer_ignorelist : Error<
255-
"failed to %select{load|parse}0 malformed sanitizer ignorelist: '%1'">;
255+
"malformed sanitizer ignorelist: '%0'">;
256256
def err_drv_malformed_sanitizer_coverage_allowlist : Error<
257-
"failed to %select{load|parse}0 malformed sanitizer coverage allowlist: '%1'">;
257+
"malformed sanitizer coverage allowlist: '%0'">;
258258
def err_drv_malformed_sanitizer_coverage_ignorelist : Error<
259-
"failed to %select{load|parse}0 malformed sanitizer coverage ignorelist: '%1'">;
259+
"malformed sanitizer coverage ignorelist: '%0'">;
260260
def err_drv_malformed_sanitizer_metadata_ignorelist : Error<
261-
"failed to %select{load|parse}0 malformed sanitizer metadata ignorelist: '%1'">;
261+
"malformed sanitizer metadata ignorelist: '%0'">;
262262
def err_drv_unsupported_static_sanitizer_darwin : Error<
263263
"static %0 runtime is not supported on darwin">;
264264
def err_drv_duplicate_config : Error<

clang/include/clang/Basic/DiagnosticFrontendKinds.td

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,6 @@ def warn_profile_data_misexpect : Warning<
370370
"potential performance regression from use of __builtin_expect(): "
371371
"annotation was correct on %0 of profiled executions">,
372372
BackendInfo, InGroup<MisExpect>;
373-
def err_sanitize_ignorelist_failure : Error<
374-
"failed to %select{load|parse}0 sanitizer ignorelist file: '%1'">;
375373
} // end of instrumentation issue category
376374

377375
def err_extract_api_ignores_file_not_found :

clang/include/clang/Basic/NoSanitizeList.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ class NoSanitizeList {
3333
StringRef Category) const;
3434

3535
public:
36-
NoSanitizeList(SourceManager &SM);
36+
NoSanitizeList(const std::vector<std::string> &NoSanitizeListPaths,
37+
SourceManager &SM);
3738
~NoSanitizeList();
38-
bool init(const std::vector<std::string> &Paths,
39-
std::pair<unsigned, std::string> &Error);
4039
bool containsGlobal(SanitizerMask Mask, StringRef GlobalName,
4140
StringRef Category = StringRef()) const;
4241
bool containsType(SanitizerMask Mask, StringRef MangledTypeName,

clang/include/clang/Basic/SanitizerSpecialCaseList.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#ifndef LLVM_CLANG_BASIC_SANITIZERSPECIALCASELIST_H
1515
#define LLVM_CLANG_BASIC_SANITIZERSPECIALCASELIST_H
1616

17-
#include "clang/Basic/Diagnostic.h"
1817
#include "clang/Basic/LLVM.h"
1918
#include "clang/Basic/Sanitizers.h"
2019
#include "llvm/ADT/StringRef.h"
@@ -35,7 +34,11 @@ class SanitizerSpecialCaseList : public llvm::SpecialCaseList {
3534
public:
3635
static std::unique_ptr<SanitizerSpecialCaseList>
3736
create(const std::vector<std::string> &Paths, llvm::vfs::FileSystem &VFS,
38-
std::pair<unsigned, std::string> &Error);
37+
std::string &Error);
38+
39+
static std::unique_ptr<SanitizerSpecialCaseList>
40+
createOrDie(const std::vector<std::string> &Paths,
41+
llvm::vfs::FileSystem &VFS);
3942

4043
// Query ignorelisted entries if any bit in Mask matches the entry's section.
4144
bool inSection(SanitizerMask Mask, StringRef Prefix, StringRef Query,

clang/lib/AST/ASTContext.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
#include "clang/Basic/AddressSpaces.h"
5151
#include "clang/Basic/Builtins.h"
5252
#include "clang/Basic/CommentOptions.h"
53-
#include "clang/Basic/DiagnosticFrontend.h"
5453
#include "clang/Basic/ExceptionSpecificationType.h"
5554
#include "clang/Basic/IdentifierTable.h"
5655
#include "clang/Basic/LLVM.h"
@@ -945,7 +944,7 @@ ASTContext::ASTContext(LangOptions &LOpts, SourceManager &SM,
945944
DependentBitIntTypes(this_()), SubstTemplateTemplateParmPacks(this_()),
946945
DeducedTemplates(this_()), ArrayParameterTypes(this_()),
947946
CanonTemplateTemplateParms(this_()), SourceMgr(SM), LangOpts(LOpts),
948-
NoSanitizeL(new NoSanitizeList(SM)),
947+
NoSanitizeL(new NoSanitizeList(LangOpts.NoSanitizeFiles, SM)),
949948
XRayFilter(new XRayFunctionFilter(LangOpts.XRayAlwaysInstrumentFiles,
950949
LangOpts.XRayNeverInstrumentFiles,
951950
LangOpts.XRayAttrListFiles, SM)),
@@ -1698,15 +1697,6 @@ ASTContext::getRelocationInfoForCXXRecord(const CXXRecordDecl *RD) const {
16981697
return std::nullopt;
16991698
}
17001699

1701-
void ASTContext::initSanitizers(const LangOptions &LangOpts,
1702-
SourceManager &SM) {
1703-
std::pair<unsigned, std::string> Error;
1704-
if (!NoSanitizeL->init(LangOpts.NoSanitizeFiles, Error)) {
1705-
SM.getDiagnostics().Report(diag::err_sanitize_ignorelist_failure)
1706-
<< Error.first << Error.second;
1707-
}
1708-
}
1709-
17101700
void ASTContext::setRelocationInfoForCXXRecord(
17111701
const CXXRecordDecl *RD, CXXRecordDeclRelocationInfo Info) {
17121702
assert(RD);

clang/lib/Basic/NoSanitizeList.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919

2020
using namespace clang;
2121

22-
NoSanitizeList::NoSanitizeList(SourceManager &SM) : SM(SM) {}
22+
NoSanitizeList::NoSanitizeList(const std::vector<std::string> &NoSanitizePaths,
23+
SourceManager &SM)
24+
: SSCL(SanitizerSpecialCaseList::createOrDie(
25+
NoSanitizePaths, SM.getFileManager().getVirtualFileSystem())),
26+
SM(SM) {}
2327

2428
NoSanitizeList::~NoSanitizeList() = default;
2529

@@ -38,13 +42,6 @@ bool NoSanitizeList::containsPrefix(SanitizerMask Mask, StringRef Prefix,
3842
return San == llvm::SpecialCaseList::NotFound || NoSan > San;
3943
}
4044

41-
bool NoSanitizeList::init(const std::vector<std::string> &Paths,
42-
std::pair<unsigned, std::string> &Error) {
43-
SSCL = SanitizerSpecialCaseList::create(
44-
Paths, SM.getFileManager().getVirtualFileSystem(), Error);
45-
return SSCL != nullptr;
46-
}
47-
4845
bool NoSanitizeList::containsGlobal(SanitizerMask Mask, StringRef GlobalName,
4946
StringRef Category) const {
5047
return containsPrefix(Mask, "global", GlobalName, Category);

clang/lib/Basic/ProfileList.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ProfileSpecialCaseList : public llvm::SpecialCaseList {
2626
public:
2727
static std::unique_ptr<ProfileSpecialCaseList>
2828
create(const std::vector<std::string> &Paths, llvm::vfs::FileSystem &VFS,
29-
std::pair<unsigned, std::string> &Error);
29+
std::string &Error);
3030

3131
static std::unique_ptr<ProfileSpecialCaseList>
3232
createOrDie(const std::vector<std::string> &Paths,
@@ -44,8 +44,7 @@ class ProfileSpecialCaseList : public llvm::SpecialCaseList {
4444

4545
std::unique_ptr<ProfileSpecialCaseList>
4646
ProfileSpecialCaseList::create(const std::vector<std::string> &Paths,
47-
llvm::vfs::FileSystem &VFS,
48-
std::pair<unsigned, std::string> &Error) {
47+
llvm::vfs::FileSystem &VFS, std::string &Error) {
4948
auto PSCL = std::make_unique<ProfileSpecialCaseList>();
5049
if (PSCL->createInternal(Paths, VFS, Error))
5150
return PSCL;
@@ -55,11 +54,10 @@ ProfileSpecialCaseList::create(const std::vector<std::string> &Paths,
5554
std::unique_ptr<ProfileSpecialCaseList>
5655
ProfileSpecialCaseList::createOrDie(const std::vector<std::string> &Paths,
5756
llvm::vfs::FileSystem &VFS) {
58-
std::pair<unsigned, std::string> Error;
57+
std::string Error;
5958
if (auto PSCL = create(Paths, VFS, Error))
6059
return PSCL;
61-
// TODO: add init function and use diagnose instead fo report_fatal_error
62-
llvm::report_fatal_error(llvm::Twine(Error.second));
60+
llvm::report_fatal_error(llvm::Twine(Error));
6361
}
6462

6563
} // namespace clang

clang/lib/Basic/SanitizerSpecialCaseList.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using namespace clang;
1818
std::unique_ptr<SanitizerSpecialCaseList>
1919
SanitizerSpecialCaseList::create(const std::vector<std::string> &Paths,
2020
llvm::vfs::FileSystem &VFS,
21-
std::pair<unsigned, std::string> &Error) {
21+
std::string &Error) {
2222
std::unique_ptr<clang::SanitizerSpecialCaseList> SSCL(
2323
new SanitizerSpecialCaseList());
2424
if (SSCL->createInternal(Paths, VFS, Error)) {
@@ -28,6 +28,15 @@ SanitizerSpecialCaseList::create(const std::vector<std::string> &Paths,
2828
return nullptr;
2929
}
3030

31+
std::unique_ptr<SanitizerSpecialCaseList>
32+
SanitizerSpecialCaseList::createOrDie(const std::vector<std::string> &Paths,
33+
llvm::vfs::FileSystem &VFS) {
34+
std::string Error;
35+
if (auto SSCL = create(Paths, VFS, Error))
36+
return SSCL;
37+
llvm::report_fatal_error(StringRef(Error));
38+
}
39+
3140
void SanitizerSpecialCaseList::createSanitizerSections() {
3241
for (auto &S : Sections) {
3342
SanitizerMask Mask;

clang/lib/Driver/SanitizerArgs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,11 @@ static void validateSpecialCaseListFormat(const Driver &D,
181181
if (SCLFiles.empty())
182182
return;
183183

184-
std::pair<unsigned, std::string> BLError;
184+
std::string BLError;
185185
std::unique_ptr<llvm::SpecialCaseList> SCL(
186186
llvm::SpecialCaseList::create(SCLFiles, D.getVFS(), BLError));
187187
if (!SCL && DiagnoseErrors)
188-
D.Diag(MalformedSCLErrorDiagID) << BLError.first << BLError.second;
188+
D.Diag(MalformedSCLErrorDiagID) << BLError;
189189
}
190190

191191
static void addDefaultIgnorelists(const Driver &D, SanitizerMask Kinds,

0 commit comments

Comments
 (0)