forked from OSchip/llvm-project
Append -fno-assume-sane-operator-new in ASan builds.
This should help LSan detect leaks where operator new would otherwise be optimized out. llvm-svn: 229498
This commit is contained in:
parent
1618543e5e
commit
2ba8778157
|
@ -424,8 +424,13 @@ void SanitizerArgs::addArgs(const llvm::opt::ArgList &Args,
|
||||||
if (SanitizeCoverage)
|
if (SanitizeCoverage)
|
||||||
CmdArgs.push_back(Args.MakeArgString("-fsanitize-coverage=" +
|
CmdArgs.push_back(Args.MakeArgString("-fsanitize-coverage=" +
|
||||||
llvm::utostr(SanitizeCoverage)));
|
llvm::utostr(SanitizeCoverage)));
|
||||||
// Workaround for PR16386.
|
// MSan: Workaround for PR16386.
|
||||||
if (Sanitizers.has(SanitizerKind::Memory))
|
// 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"));
|
CmdArgs.push_back(Args.MakeArgString("-fno-assume-sane-operator-new"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,6 +157,8 @@
|
||||||
|
|
||||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN
|
// 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"
|
// 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
|
// 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='
|
// CHECK-DIAG1: unsupported argument 'zzz' to option 'fsanitize='
|
||||||
|
|
Loading…
Reference in New Issue