diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp index a0d6919c6dc8d0..04b39d29e7342f 100644 --- a/clang/lib/Driver/SanitizerArgs.cpp +++ b/clang/lib/Driver/SanitizerArgs.cpp @@ -530,6 +530,16 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC, } Add &= Supported; + // Msan is not supported on Android + if ((Add & SanitizerKind::Memory) && TC.getTriple().isAndroid()) { + if (DiagnoseErrors) { + D.Diag(diag::warn_drv_unsupported_option_for_target) + << "-fsanitize=memory" << Triple.str(); + } + DiagnosedKinds |= SanitizerKind::Memory; + Add &= ~SanitizerKind::Memory; + } + // Test for -fno-rtti + explicit -fsanitizer=vptr before expanding groups // so we don't error out if -fno-rtti and -fsanitize=undefined were // passed. diff --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c index 1d3caec748d77a..55b51ed29b0e65 100644 --- a/clang/test/Driver/fsanitize.c +++ b/clang/test/Driver/fsanitize.c @@ -399,6 +399,11 @@ // RUN: %clang --target=arm-linux-androideabi %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ANDROID-NO-ASAN // CHECK-ANDROID-NO-ASAN: "-mrelocation-model" "pic" +// RUN: %clang --target=aarch64-linux-android -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-ANDROID +// RUN: %clang --target=i386-linux-android -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-ANDROID +// RUN: %clang --target=x86_64-linux-android -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-ANDROID +// CHECK-MSAN-ANDROID: ignoring '-fsanitize=memory' option as it is not currently supported for target + // RUN: %clang --target=x86_64-linux-gnu %s -fsanitize=undefined -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER-UBSAN // RUN: %clang --target=x86_64-linux-gnu %s -fsanitize=undefined -fsanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER-UBSAN // RUN: %clang --target=x86_64-linux-gnu %s -fsanitize=undefined -fsanitize-recover=all -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER-UBSAN