Skip to content

Commit 3e42b05

Browse files
committed
Move the check into Linux.cpp
1 parent 035c7d9 commit 3e42b05

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

clang/lib/Driver/SanitizerArgs.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -530,16 +530,6 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
530530
}
531531
Add &= Supported;
532532

533-
// Msan is not supported on Android
534-
if ((Add & SanitizerKind::Memory) && TC.getTriple().isAndroid()) {
535-
if (DiagnoseErrors) {
536-
D.Diag(diag::warn_drv_unsupported_option_for_target)
537-
<< "-fsanitize=memory" << Triple.str();
538-
}
539-
DiagnosedKinds |= SanitizerKind::Memory;
540-
Add &= ~SanitizerKind::Memory;
541-
}
542-
543533
// Test for -fno-rtti + explicit -fsanitizer=vptr before expanding groups
544534
// so we don't error out if -fno-rtti and -fsanitize=undefined were
545535
// passed.

clang/lib/Driver/ToolChains/Linux.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,7 @@ SanitizerMask Linux::getSupportedSanitizers() const {
823823
const bool IsRISCV64 = getTriple().getArch() == llvm::Triple::riscv64;
824824
const bool IsSystemZ = getTriple().getArch() == llvm::Triple::systemz;
825825
const bool IsHexagon = getTriple().getArch() == llvm::Triple::hexagon;
826+
const bool IsAndroid = getTriple().isAndroid();
826827
SanitizerMask Res = ToolChain::getSupportedSanitizers();
827828
Res |= SanitizerKind::Address;
828829
Res |= SanitizerKind::PointerCompare;
@@ -831,7 +832,6 @@ SanitizerMask Linux::getSupportedSanitizers() const {
831832
Res |= SanitizerKind::Fuzzer;
832833
Res |= SanitizerKind::FuzzerNoLink;
833834
Res |= SanitizerKind::KernelAddress;
834-
Res |= SanitizerKind::Memory;
835835
Res |= SanitizerKind::Vptr;
836836
Res |= SanitizerKind::SafeStack;
837837
if (IsX86_64 || IsMIPS64 || IsAArch64 || IsLoongArch64)
@@ -857,6 +857,8 @@ SanitizerMask Linux::getSupportedSanitizers() const {
857857
}
858858
if (IsX86_64)
859859
Res |= SanitizerKind::NumericalStability;
860+
if (!IsAndroid)
861+
Res |= SanitizerKind::Memory;
860862

861863
// Work around "Cannot represent a difference across sections".
862864
if (getTriple().getArch() == llvm::Triple::ppc64)

clang/test/Driver/fsanitize.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,10 @@
399399
// RUN: %clang --target=arm-linux-androideabi %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ANDROID-NO-ASAN
400400
// CHECK-ANDROID-NO-ASAN: "-mrelocation-model" "pic"
401401

402-
// RUN: %clang --target=aarch64-linux-android -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-ANDROID
403-
// RUN: %clang --target=i386-linux-android -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-ANDROID
404-
// RUN: %clang --target=x86_64-linux-android -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-ANDROID
405-
// CHECK-MSAN-ANDROID: ignoring '-fsanitize=memory' option as it is not currently supported for target
402+
// RUN: not %clang --target=aarch64-linux-android -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-ANDROID
403+
// RUN: not %clang --target=i386-linux-android -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-ANDROID
404+
// RUN: not %clang --target=x86_64-linux-android -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-ANDROID
405+
// CHECK-MSAN-ANDROID: unsupported option '-fsanitize=memory' for target
406406

407407
// RUN: %clang --target=x86_64-linux-gnu %s -fsanitize=undefined -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER-UBSAN
408408
// RUN: %clang --target=x86_64-linux-gnu %s -fsanitize=undefined -fsanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER-UBSAN

0 commit comments

Comments
 (0)