Skip to content

Commit c5acd34

Browse files
committed
Driver: Add integer sanitizers to trapping group automatically.
In D86000 we added a new sanitizer to the integer group without adding it to the trapping group. This broke usage of -fsanitize=integer -fsanitize-trap=integer or -fsanitize=integer -fsanitize-minimal-runtime. I think we can reasonably expect any new integer sanitizers to be compatible with trapping and the minimal runtime, so add them to the trapping group automatically. Also add a test to ensure that any future additions of sanitizers to the integer group will most likely result in test failures which would lead to updates to the minimal runtime if necessary. For this particular sanitizer no updates are required because it uses the existing shift_out_of_bounds callback function. Differential Revision: https://reviews.llvm.org/D89766
1 parent 332ff48 commit c5acd34

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

clang/lib/Driver/SanitizerArgs.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ static const SanitizerMask AlwaysRecoverable =
6060
SanitizerKind::KernelAddress | SanitizerKind::KernelHWAddress;
6161
static const SanitizerMask NeedsLTO = SanitizerKind::CFI;
6262
static const SanitizerMask TrappingSupported =
63-
(SanitizerKind::Undefined & ~SanitizerKind::Vptr) |
64-
SanitizerKind::UnsignedIntegerOverflow | SanitizerKind::ImplicitConversion |
63+
(SanitizerKind::Undefined & ~SanitizerKind::Vptr) | SanitizerKind::Integer |
6564
SanitizerKind::Nullability | SanitizerKind::LocalBounds |
6665
SanitizerKind::CFI | SanitizerKind::FloatDivideByZero |
6766
SanitizerKind::ObjCCast;

clang/test/Driver/fsanitize.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,13 @@
786786
// CHECK-UBSAN-MINIMAL: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|builtin|returns-nonnull-attribute|nonnull-attribute),?){17}"}}
787787
// CHECK-UBSAN-MINIMAL: "-fsanitize-minimal-runtime"
788788

789+
// RUN: %clang -target x86_64-linux-gnu -fsanitize=integer -fsanitize-trap=integer %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-INTSAN-TRAP
790+
// CHECK-INTSAN-TRAP: "-fsanitize-trap=integer-divide-by-zero,shift-base,shift-exponent,signed-integer-overflow,unsigned-integer-overflow,unsigned-shift-base,implicit-unsigned-integer-truncation,implicit-signed-integer-truncation,implicit-integer-sign-change"
791+
792+
// RUN: %clang -target x86_64-linux-gnu -fsanitize=integer -fsanitize-minimal-runtime %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-INTSAN-MINIMAL
793+
// CHECK-INTSAN-MINIMAL: "-fsanitize=integer-divide-by-zero,shift-base,shift-exponent,signed-integer-overflow,unsigned-integer-overflow,unsigned-shift-base,implicit-unsigned-integer-truncation,implicit-signed-integer-truncation,implicit-integer-sign-change"
794+
// CHECK-INTSAN-MINIMAL: "-fsanitize-minimal-runtime"
795+
789796
// RUN: %clang -target aarch64-linux-android -march=armv8-a+memtag -fsanitize=memtag -fsanitize-minimal-runtime %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MEMTAG-MINIMAL
790797
// CHECK-MEMTAG-MINIMAL: "-fsanitize=memtag"
791798
// CHECK-MEMTAG-MINIMAL: "-fsanitize-minimal-runtime"

0 commit comments

Comments
 (0)