forked from OSchip/llvm-project
Add -fno-sanitize-address-use-after-scope flag
Reviewers: eugenis Differential Revision: https://reviews.llvm.org/D25453 llvm-svn: 283801
This commit is contained in:
parent
edce6e9126
commit
a77ac1b214
|
@ -687,6 +687,9 @@ def fsanitize_address_field_padding : Joined<["-"], "fsanitize-address-field-pad
|
|||
def fsanitize_address_use_after_scope : Flag<["-"], "fsanitize-address-use-after-scope">,
|
||||
Group<f_clang_Group>, Flags<[CC1Option]>,
|
||||
HelpText<"Enable use-after-scope detection in AddressSanitizer">;
|
||||
def fno_sanitize_address_use_after_scope : Flag<["-"], "fno-sanitize-address-use-after-scope">,
|
||||
Group<f_clang_Group>, Flags<[CC1Option]>,
|
||||
HelpText<"Disable use-after-scope detection in AddressSanitizer">;
|
||||
def fsanitize_recover : Flag<["-"], "fsanitize-recover">, Group<f_clang_Group>,
|
||||
Flags<[CoreOption]>;
|
||||
def fno_sanitize_recover : Flag<["-"], "fno-sanitize-recover">,
|
||||
|
|
|
@ -559,14 +559,13 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
|
|||
D.Diag(clang::diag::note_drv_address_sanitizer_debug_runtime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AsanUseAfterScope =
|
||||
Args.hasArg(options::OPT_fsanitize_address_use_after_scope);
|
||||
if (AsanUseAfterScope && !(AllAddedKinds & Address)) {
|
||||
D.Diag(clang::diag::err_drv_argument_only_allowed_with)
|
||||
<< "-fsanitize-address-use-after-scope"
|
||||
<< "-fsanitize=address";
|
||||
if (Arg *A = Args.getLastArg(
|
||||
options::OPT_fsanitize_address_use_after_scope,
|
||||
options::OPT_fno_sanitize_address_use_after_scope)) {
|
||||
AsanUseAfterScope = A->getOption().getID() ==
|
||||
options::OPT_fsanitize_address_use_after_scope;
|
||||
}
|
||||
}
|
||||
|
||||
// Parse -link-cxx-sanitizer flag.
|
||||
|
|
|
@ -732,8 +732,11 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
|
|||
Args.hasArg(OPT_fsanitize_memory_use_after_dtor);
|
||||
Opts.SanitizeCfiCrossDso = Args.hasArg(OPT_fsanitize_cfi_cross_dso);
|
||||
Opts.SanitizeStats = Args.hasArg(OPT_fsanitize_stats);
|
||||
Opts.SanitizeAddressUseAfterScope =
|
||||
Args.hasArg(OPT_fsanitize_address_use_after_scope);
|
||||
if (Arg *A = Args.getLastArg(OPT_fsanitize_address_use_after_scope,
|
||||
OPT_fno_sanitize_address_use_after_scope)) {
|
||||
Opts.SanitizeAddressUseAfterScope =
|
||||
A->getOption().getID() == OPT_fsanitize_address_use_after_scope;
|
||||
}
|
||||
Opts.SSPBufferSize =
|
||||
getLastArgIntValue(Args, OPT_stack_protector_buffer_size, 8, Diags);
|
||||
Opts.StackRealignment = Args.hasArg(OPT_mstackrealign);
|
||||
|
|
|
@ -108,14 +108,20 @@
|
|||
// RUN: %clang -target x86_64-linux-gnu -fsanitize=efficiency-working-set,kernel-address -pie -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANE-SANKA
|
||||
// CHECK-SANE-SANKA: '-fsanitize=efficiency-{{.*}}' not allowed with '-fsanitize=kernel-address'
|
||||
|
||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize-address-use-after-scope %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-USE-AFTER-SCOPE
|
||||
// CHECK-ONLY-USE-AFTER-SCOPE: '-fsanitize-address-use-after-scope' only allowed with '-fsanitize=address'
|
||||
|
||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-address-use-after-scope %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-USE-AFTER-SCOPE
|
||||
// CHECK-USE-AFTER-SCOPE: -cc1{{.*}}-fsanitize-address-use-after-scope
|
||||
|
||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-NO-USE-AFTER-SCOPE
|
||||
// CHECK-ASAN-NO-USE-AFTER-SCOPE-NOT: -cc1{{.*}}-fsanitize-address-use-after-scope
|
||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fno-sanitize-address-use-after-scope %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-USE-AFTER-SCOPE-OFF
|
||||
// CHECK-USE-AFTER-SCOPE-OFF-NOT: -cc1{{.*}}address-use-after-scope
|
||||
|
||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fno-sanitize-address-use-after-scope -fsanitize-address-use-after-scope %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-USE-AFTER-SCOPE-BOTH
|
||||
// CHECK-USE-AFTER-SCOPE-BOTH: -cc1{{.*}}-fsanitize-address-use-after-scope
|
||||
|
||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-address-use-after-scope -fno-sanitize-address-use-after-scope %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-USE-AFTER-SCOPE-BOTH-OFF
|
||||
// CHECK-USE-AFTER-SCOPE-BOTH-OFF-NOT: -cc1{{.*}}address-use-after-scope
|
||||
|
||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE
|
||||
// CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE-NOT: -cc1{{.*}}address-use-after-scope
|
||||
|
||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize-memory-track-origins -pie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-TRACK-ORIGINS
|
||||
// CHECK-ONLY-TRACK-ORIGINS: warning: argument unused during compilation: '-fsanitize-memory-track-origins'
|
||||
|
|
Loading…
Reference in New Issue