Skip to content

Commit 65f1ecd

Browse files
authored
Merge pull request #68063 from etcwilde/ewilde/scudo-rename
2 parents d454890 + bf4dadc commit 65f1ecd

File tree

5 files changed

+22
-32
lines changed

5 files changed

+22
-32
lines changed

include/swift/Basic/Sanitizers.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ SANITIZER(0, Address, address, asan)
2424
SANITIZER(1, Thread, thread, tsan)
2525
SANITIZER(2, Undefined, undefined, ubsan)
2626
SANITIZER(3, Fuzzer, fuzzer, fuzzer)
27-
SANITIZER(4, Scudo, scudo, scudo)
27+
SANITIZER(4, Scudo, scudo, scudo_standalone)
2828

2929
#undef SANITIZER

lib/Option/SanitizerOptions.cpp

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -182,36 +182,27 @@ OptionSet<SanitizerKind> swift::parseSanitizerArgValues(
182182
+ toStringRef(SanitizerKind::Thread)).toStringRef(b2));
183183
}
184184

185-
// Scudo can only be run with ubsan.
186-
if (sanitizerSet & SanitizerKind::Scudo) {
187-
OptionSet<SanitizerKind> allowedSet;
188-
allowedSet |= SanitizerKind::Scudo;
189-
allowedSet |= SanitizerKind::Undefined;
190-
191-
auto forbiddenOptions = sanitizerSet - allowedSet;
192-
193-
if (forbiddenOptions) {
194-
SanitizerKind forbidden;
195-
196-
if (forbiddenOptions & SanitizerKind::Address) {
197-
forbidden = SanitizerKind::Address;
198-
} else if (forbiddenOptions & SanitizerKind::Thread) {
199-
forbidden = SanitizerKind::Thread;
200-
} else {
201-
assert(forbiddenOptions & SanitizerKind::Fuzzer);
202-
forbidden = SanitizerKind::Fuzzer;
185+
// Scudo must be run standalone
186+
if (sanitizerSet.contains(SanitizerKind::Scudo) &&
187+
!sanitizerSet.containsOnly(SanitizerKind::Scudo)) {
188+
auto diagnoseSanitizerKind = [&Diags, A, &sanitizerSet](SanitizerKind kind) {
189+
// Don't diagnose Scudo, but diagnose anything else
190+
if (kind != SanitizerKind::Scudo && sanitizerSet.contains(kind)) {
191+
SmallString<128> b1;
192+
SmallString<128> b2;
193+
Diags.diagnose(SourceLoc(), diag::error_argument_not_allowed_with,
194+
(A->getOption().getPrefixedName()
195+
+ toStringRef(SanitizerKind::Scudo)).toStringRef(b1),
196+
(A->getOption().getPrefixedName()
197+
+ toStringRef(kind)).toStringRef(b2));
203198
}
199+
};
204200

205-
SmallString<128> b1;
206-
SmallString<128> b2;
207-
Diags.diagnose(SourceLoc(), diag::error_argument_not_allowed_with,
208-
(A->getOption().getPrefixedName()
209-
+ toStringRef(SanitizerKind::Scudo)).toStringRef(b1),
210-
(A->getOption().getPrefixedName()
211-
+ toStringRef(forbidden)).toStringRef(b2));
212-
}
213-
}
201+
#define SANITIZER(enm, kind, name, file) \
202+
diagnoseSanitizerKind(SanitizerKind::kind);
203+
#include "swift/Basic/Sanitizers.def"
214204

205+
}
215206
return sanitizerSet;
216207
}
217208

test/Driver/sanitize_scudo.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
// RUN: not %swiftc_driver -resource-dir %S/Inputs/fake-resource-dir/lib/swift/ -driver-print-jobs -sanitize=scudo,address -target x86_64-unknown-linux-gnu %s 2>&1 | %FileCheck -check-prefix=SCUDO_ASAN %s
1313
// RUN: not %swiftc_driver -resource-dir %S/Inputs/fake-resource-dir/lib/swift/ -driver-print-jobs -sanitize=scudo,thread -target x86_64-unknown-linux-gnu %s 2>&1 | %FileCheck -check-prefix=SCUDO_TSAN %s
14-
// RUN: %swiftc_driver -resource-dir %S/Inputs/fake-resource-dir/lib/swift/ -driver-print-jobs -sanitize=scudo,undefined -target x86_64-unknown-linux-gnu %s 2>&1 | %FileCheck -check-prefix=SCUDO_UBSAN_LINUX %s
14+
// RUN: not %swiftc_driver -resource-dir %S/Inputs/fake-resource-dir/lib/swift/ -driver-print-jobs -sanitize=scudo,undefined -target x86_64-unknown-linux-gnu %s 2>&1 | %FileCheck -check-prefix=SCUDO_UBSAN %s
1515

1616

1717
/*
@@ -34,7 +34,6 @@
3434

3535
// SCUDO_ASAN: argument '-sanitize=scudo' is not allowed with '-sanitize=address'
3636
// SCUDO_TSAN: argument '-sanitize=scudo' is not allowed with '-sanitize=thread'
37-
// SCUDO_UBSAN_LINUX: -fsanitize=undefined,scudo
37+
// SCUDO_UBSAN: argument '-sanitize=scudo' is not allowed with '-sanitize=undefined'
3838
// SCUDO_LIBRARY_LINUX: bin{{/|\\\\}}clang
3939
// SCUDO_LIBRARY_LINUX-NOT: -fsanitize=scudo
40-

test/Sanitizers/scudo.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %target-swiftc_driver %s -g -sanitize=scudo -o %t_scudo-binary
2-
// RUN: not %target-run %t_scudo-binary 2>&1 | %FileCheck %s
2+
// RUN: not --crash %target-run %t_scudo-binary 2>&1 | %FileCheck %s
33
// REQUIRES: executable_test
44
// REQUIRES: OS=linux-gnu
55
// REQUIRES: scudo_runtime

0 commit comments

Comments
 (0)