forked from OSchip/llvm-project
[ASan] Make -fsanitize=address always imply -fsanitize=init-order
llvm-svn: 177391
This commit is contained in:
parent
e8504e269f
commit
b2b0e3f00a
|
@ -90,14 +90,20 @@ class SanitizerArgs {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Parse a single value from a -fsanitize= or -fno-sanitize= value list.
|
/// Parse a single value from a -fsanitize= or -fno-sanitize= value list.
|
||||||
/// Returns a member of the \c SanitizeKind enumeration, or \c 0 if \p Value
|
/// Returns OR of members of the \c SanitizeKind enumeration, or \c 0
|
||||||
/// is not known.
|
/// if \p Value is not known.
|
||||||
static unsigned parse(const char *Value) {
|
static unsigned parse(const char *Value) {
|
||||||
return llvm::StringSwitch<SanitizeKind>(Value)
|
unsigned ParsedKind = llvm::StringSwitch<SanitizeKind>(Value)
|
||||||
#define SANITIZER(NAME, ID) .Case(NAME, ID)
|
#define SANITIZER(NAME, ID) .Case(NAME, ID)
|
||||||
#define SANITIZER_GROUP(NAME, ID, ALIAS) .Case(NAME, ID)
|
#define SANITIZER_GROUP(NAME, ID, ALIAS) .Case(NAME, ID)
|
||||||
#include "clang/Basic/Sanitizers.def"
|
#include "clang/Basic/Sanitizers.def"
|
||||||
.Default(SanitizeKind());
|
.Default(SanitizeKind());
|
||||||
|
// Assume -fsanitize=address implies -fsanitize=init-order.
|
||||||
|
// FIXME: This should be either specified in Sanitizers.def, or go away when
|
||||||
|
// we get rid of "-fsanitize=init-order" flag at all.
|
||||||
|
if (ParsedKind & Address)
|
||||||
|
ParsedKind |= InitOrder;
|
||||||
|
return ParsedKind;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parse a -fsanitize= or -fno-sanitize= argument's values, diagnosing any
|
/// Parse a -fsanitize= or -fno-sanitize= argument's values, diagnosing any
|
||||||
|
|
|
@ -1475,8 +1475,6 @@ SanitizerArgs::SanitizerArgs(const Driver &D, const ArgList &Args)
|
||||||
AsanZeroBaseShadow(false) {
|
AsanZeroBaseShadow(false) {
|
||||||
unsigned AllKinds = 0; // All kinds of sanitizers that were turned on
|
unsigned AllKinds = 0; // All kinds of sanitizers that were turned on
|
||||||
// at least once (possibly, disabled further).
|
// at least once (possibly, disabled further).
|
||||||
unsigned AllRemovedKinds = 0; // All kinds of sanitizers that were explicitly
|
|
||||||
// removed at least once.
|
|
||||||
for (ArgList::const_iterator I = Args.begin(), E = Args.end(); I != E; ++I) {
|
for (ArgList::const_iterator I = Args.begin(), E = Args.end(); I != E; ++I) {
|
||||||
unsigned Add, Remove;
|
unsigned Add, Remove;
|
||||||
if (!parse(D, Args, *I, Add, Remove, true))
|
if (!parse(D, Args, *I, Add, Remove, true))
|
||||||
|
@ -1485,12 +1483,6 @@ SanitizerArgs::SanitizerArgs(const Driver &D, const ArgList &Args)
|
||||||
Kind |= Add;
|
Kind |= Add;
|
||||||
Kind &= ~Remove;
|
Kind &= ~Remove;
|
||||||
AllKinds |= Add;
|
AllKinds |= Add;
|
||||||
AllRemovedKinds |= Remove;
|
|
||||||
}
|
|
||||||
// Assume -fsanitize=address implies -fsanitize=init-order, if the latter is
|
|
||||||
// not disabled explicitly.
|
|
||||||
if ((Kind & Address) != 0 && (AllRemovedKinds & InitOrder) == 0) {
|
|
||||||
Kind |= InitOrder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UbsanTrapOnError =
|
UbsanTrapOnError =
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize=address-full %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-FULL
|
// RUN: %clang -target x86_64-linux-gnu -fsanitize=address-full %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-FULL
|
||||||
// CHECK-ASAN-FULL: "-fsanitize={{((address|init-order|use-after-return|use-after-scope),?){4}"}}
|
// CHECK-ASAN-FULL: "-fsanitize={{((address|init-order|use-after-return|use-after-scope),?){4}"}}
|
||||||
|
|
||||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-IMPLIED-INIT-ORDER
|
// RUN: %clang -target x86_64-linux-gnu -fno-sanitize=init-order -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-IMPLIED-INIT-ORDER
|
||||||
// CHECK-ASAN-IMPLIED-INIT-ORDER: "-fsanitize={{((address|init-order),?){2}"}}
|
// CHECK-ASAN-IMPLIED-INIT-ORDER: "-fsanitize={{((address|init-order),?){2}"}}
|
||||||
|
|
||||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fno-sanitize=init-order %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-NO-IMPLIED-INIT-ORDER
|
// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fno-sanitize=init-order %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-NO-IMPLIED-INIT-ORDER
|
||||||
|
|
Loading…
Reference in New Issue