Index: lib/Driver/ToolChains.cpp =================================================================== --- lib/Driver/ToolChains.cpp +++ lib/Driver/ToolChains.cpp @@ -363,9 +363,24 @@ // Sanitizer runtime libraries requires C++. AddCXXStdlibLibArgs(Args, CmdArgs); } - // ASan is not supported on watchOS. - assert(isTargetMacOS() || isTargetIOSSimulator()); - StringRef OS = isTargetMacOS() ? "osx" : "iossim"; + + StringRef OS = ""; + if (isTargetMacOS()) + OS = "osx"; + if (isTargetWatchOSSimulator()) + OS = "watchossim"; + if (isTargetWatchOS()) + OS = "watchos"; + if (isTargetIOSSimulator()) + OS = "iossim"; + if (isTargetIPhoneOS()) + OS = "ios"; + if (isTargetTvOSSimulator()) + OS = "tvossim"; + if (isTargetTvOS()) + OS = "tvos"; + assert(!OS.empty()); + AddLinkRuntimeLib( Args, CmdArgs, (Twine("libclang_rt.") + Sanitizer + "_" + OS + "_dynamic.dylib").str(), @@ -1213,8 +1228,7 @@ SanitizerMask Darwin::getSupportedSanitizers() const { SanitizerMask Res = ToolChain::getSupportedSanitizers(); - if (isTargetMacOS() || isTargetIOSSimulator()) - Res |= SanitizerKind::Address; + Res |= SanitizerKind::Address; if (isTargetMacOS()) { if (!isMacosxVersionLT(10, 9)) Res |= SanitizerKind::Vptr; Index: test/Driver/fsanitize.c =================================================================== --- test/Driver/fsanitize.c +++ test/Driver/fsanitize.c @@ -230,7 +230,7 @@ // CHECK-VPTR-DARWIN-NEW: -fsanitize=alignment,vptr // RUN: %clang -target armv7-apple-ios7 -miphoneos-version-min=7.0 -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-IOS -// CHECK-ASAN-IOS: unsupported option '-fsanitize=address' for target 'arm-apple-ios7' +// CHECK-ASAN-IOS: -fsanitize=address // RUN: %clang -target i386-pc-openbsd -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-OPENBSD // CHECK-ASAN-OPENBSD: unsupported option '-fsanitize=address' for target 'i386-pc-openbsd'