if (SanitizeCoverage)
CmdArgs.push_back(Args.MakeArgString("-fsanitize-coverage=" +
llvm::utostr(SanitizeCoverage)));
- // Workaround for PR16386.
- if (Sanitizers.has(SanitizerKind::Memory))
+ // MSan: Workaround for PR16386.
+ // ASan: This is mainly to help LSan with cases such as
+ // https://code.google.com/p/address-sanitizer/issues/detail?id=373
+ // We can't make this conditional on -fsanitize=leak, as that flag shouldn't
+ // affect compilation.
+ if (Sanitizers.has(SanitizerKind::Memory) ||
+ Sanitizers.has(SanitizerKind::Address))
CmdArgs.push_back(Args.MakeArgString("-fno-assume-sane-operator-new"));
}
// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN
// CHECK-MSAN: "-fno-assume-sane-operator-new"
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN
+// CHECK-ASAN: "-fno-assume-sane-operator-new"
// RUN: %clang -target x86_64-linux-gnu -fsanitize=zzz %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DIAG1
// CHECK-DIAG1: unsupported argument 'zzz' to option 'fsanitize='