Skip to content

Commit 49447c0

Browse files
committed
fix: use std::pair to fix SpecialCaseList
1 parent 7a84c37 commit 49447c0

File tree

12 files changed

+36
-27
lines changed

12 files changed

+36
-27
lines changed

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-
"malformed sanitizer ignorelist: '%0'">;
255+
"failed to %select{load|parse}0 malformed sanitizer ignorelist: '%1'">;
256256
def err_drv_malformed_sanitizer_coverage_allowlist : Error<
257-
"malformed sanitizer coverage allowlist: '%0'">;
257+
"failed to %select{load|parse}0 malformed sanitizer coverage allowlist: '%1'">;
258258
def err_drv_malformed_sanitizer_coverage_ignorelist : Error<
259-
"malformed sanitizer coverage ignorelist: '%0'">;
259+
"failed to %select{load|parse}0 malformed sanitizer coverage ignorelist: '%1'">;
260260
def err_drv_malformed_sanitizer_metadata_ignorelist : Error<
261-
"malformed sanitizer metadata ignorelist: '%0'">;
261+
"failed to %select{load|parse}0 malformed sanitizer metadata ignorelist: '%1'">;
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ def warn_profile_data_misexpect : Warning<
371371
"annotation was correct on %0 of profiled executions">,
372372
BackendInfo, InGroup<MisExpect>;
373373
def err_sanitize_ignorelist_failure : Error<
374-
"failed to sanitizer ignorelist file: %0">;
374+
"failed to %select{load|parse}0 sanitizer ignorelist file: '%1'">;
375375
} // end of instrumentation issue category
376376

377377
def err_extract_api_ignores_file_not_found :

clang/include/clang/Basic/NoSanitizeList.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ class NoSanitizeList {
3535
public:
3636
NoSanitizeList(SourceManager &SM);
3737
~NoSanitizeList();
38-
bool init(const std::vector<std::string> &Paths, std::string &Error);
38+
bool init(const std::vector<std::string> &Paths,
39+
std::pair<unsigned, std::string> &Error);
3940
bool containsGlobal(SanitizerMask Mask, StringRef GlobalName,
4041
StringRef Category = StringRef()) const;
4142
bool containsType(SanitizerMask Mask, StringRef MangledTypeName,

clang/include/clang/Basic/SanitizerSpecialCaseList.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class SanitizerSpecialCaseList : public llvm::SpecialCaseList {
3535
public:
3636
static std::unique_ptr<SanitizerSpecialCaseList>
3737
create(const std::vector<std::string> &Paths, llvm::vfs::FileSystem &VFS,
38-
std::string &Error);
38+
std::pair<unsigned, std::string> &Error);
3939

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

clang/lib/AST/ASTContext.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,9 +1700,10 @@ ASTContext::getRelocationInfoForCXXRecord(const CXXRecordDecl *RD) const {
17001700

17011701
void ASTContext::initSanitizers(const LangOptions &LangOpts,
17021702
SourceManager &SM) {
1703-
std::string Error;
1703+
std::pair<unsigned, std::string> Error;
17041704
if (!NoSanitizeL->init(LangOpts.NoSanitizeFiles, Error)) {
1705-
SM.getDiagnostics().Report(diag::err_sanitize_ignorelist_failure) << Error;
1705+
SM.getDiagnostics().Report(diag::err_sanitize_ignorelist_failure)
1706+
<< Error.first << Error.second;
17061707
}
17071708
}
17081709

clang/lib/Basic/NoSanitizeList.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ bool NoSanitizeList::containsPrefix(SanitizerMask Mask, StringRef Prefix,
3939
}
4040

4141
bool NoSanitizeList::init(const std::vector<std::string> &Paths,
42-
std::string &Error) {
42+
std::pair<unsigned, std::string> &Error) {
4343
SSCL = SanitizerSpecialCaseList::create(
4444
Paths, SM.getFileManager().getVirtualFileSystem(), Error);
4545
return SSCL != nullptr;

clang/lib/Basic/ProfileList.cpp

Lines changed: 6 additions & 4 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::string &Error);
29+
std::pair<unsigned, std::string> &Error);
3030

3131
static std::unique_ptr<ProfileSpecialCaseList>
3232
createOrDie(const std::vector<std::string> &Paths,
@@ -44,7 +44,8 @@ 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, std::string &Error) {
47+
llvm::vfs::FileSystem &VFS,
48+
std::pair<unsigned, std::string> &Error) {
4849
auto PSCL = std::make_unique<ProfileSpecialCaseList>();
4950
if (PSCL->createInternal(Paths, VFS, Error))
5051
return PSCL;
@@ -54,10 +55,11 @@ ProfileSpecialCaseList::create(const std::vector<std::string> &Paths,
5455
std::unique_ptr<ProfileSpecialCaseList>
5556
ProfileSpecialCaseList::createOrDie(const std::vector<std::string> &Paths,
5657
llvm::vfs::FileSystem &VFS) {
57-
std::string Error;
58+
std::pair<unsigned, std::string> Error;
5859
if (auto PSCL = create(Paths, VFS, Error))
5960
return PSCL;
60-
llvm::report_fatal_error(llvm::Twine(Error));
61+
// TODO: add init function and use diagnose instead fo report_fatal_error
62+
llvm::report_fatal_error(llvm::Twine(Error.second));
6163
}
6264

6365
} // namespace clang

clang/lib/Basic/SanitizerSpecialCaseList.cpp

Lines changed: 1 addition & 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::string &Error) {
21+
std::pair<unsigned, std::string> &Error) {
2222
std::unique_ptr<clang::SanitizerSpecialCaseList> SSCL(
2323
new SanitizerSpecialCaseList());
2424
if (SSCL->createInternal(Paths, VFS, Error)) {

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::string BLError;
184+
std::pair<unsigned, 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;
188+
D.Diag(MalformedSCLErrorDiagID) << BLError.first << BLError.second;
189189
}
190190

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

clang/test/Driver/fsanitize-ignorelist.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
// Driver properly reports malformed ignorelist files.
5252
// RUN: not %clang --target=x86_64-linux-gnu -fsanitize=address -fsanitize-ignorelist=%t.second -fsanitize-ignorelist=%t.bad -fsanitize-ignorelist=%t.good %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-BAD-IGNORELIST
53-
// CHECK-BAD-IGNORELIST: error: malformed sanitizer ignorelist: 'error parsing file '{{.*}}.bad': malformed line 1: 'badline''
53+
// CHECK-BAD-IGNORELIST: error: failed to parse malformed sanitizer ignorelist: '{{.*}}.bad': malformed line 1: 'badline'
5454

5555
// -fno-sanitize-ignorelist disables all ignorelists specified earlier.
5656
// RUN: %clang --target=x86_64-linux-gnu -fsanitize=address -fsanitize-ignorelist=%t.good -fno-sanitize-ignorelist -fsanitize-ignorelist=%t.second %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-FIRST-DISABLED --implicit-check-not=-fsanitize-ignorelist=
@@ -74,7 +74,7 @@
7474

7575
// Check that a missing file passed to -fsanitize-system-ignorelist triggers a clean error without crashing.
7676
// RUN: not %clang --target=x86_64-linux-gnu -Xclang -fsanitize-system-ignorelist=%t.nonexistent %s -c -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-SYSTEM-IGNORELIST-NOFILE
77-
// CHECK-SYSTEM-IGNORELIST-NOFILE: error: failed to sanitizer ignorelist file: can't open file '{{.*[\\/]fsanitize-ignorelist\.c\.tmp\.nonexistent}}': {{[Nn]o such file or directory}}
77+
// CHECK-SYSTEM-IGNORELIST-NOFILE: error: failed to load sanitizer ignorelist file: '{{.*[\\/]fsanitize-ignorelist\.c\.tmp\.nonexistent}}': {{[Nn]o such file or directory}}
7878
// CHECK-SYSTEM-IGNORELIST-NOFILE-NOT: Stack dump:
7979
// CHECK-SYSTEM-IGNORELIST-NOFILE-NOT: PLEASE submit a bug report
8080
// CHECK-SYSTEM-IGNORELIST-NOFILE-NOT: diagnostic msg:

0 commit comments

Comments
 (0)