From 87e869da7ef807a5f71d70b360264f2920d303f3 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 12 Apr 2017 22:50:51 +0000 Subject: [PATCH] [clang-cl] Make all sanitizer flags available in clang-cl Summary: Use a tablegen let {} block so that new sanitizer flags are available by default in all driver modes. This should cut down on time wasted with bugs like http://crbug.com/710928. Reviewers: vitalybuka, hans Subscribers: kcc, llvm-commits Differential Revision: https://reviews.llvm.org/D31988 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300122 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Driver/Options.td | 62 ++++++++++++++++++++------------- test/Driver/fsanitize.c | 3 ++ 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 6c78078ce6..d3f839321f 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -778,65 +778,71 @@ def fno_signaling_math : Flag<["-"], "fno-signaling-math">, Group; def fjump_tables : Flag<["-"], "fjump-tables">, Group; def fno_jump_tables : Flag<["-"], "fno-jump-tables">, Group, Flags<[CC1Option]>, HelpText<"Do not use jump tables for lowering switches">; + +// Begin sanitizer flags. These should all be core options exposed in all driver +// modes. +let Flags = [CC1Option, CoreOption] in { + def fsanitize_EQ : CommaJoined<["-"], "fsanitize=">, Group, - Flags<[CC1Option, CoreOption]>, MetaVarName<"">, + MetaVarName<"">, HelpText<"Turn on runtime checks for various forms of undefined " "or suspicious behavior. See user manual for available checks">; def fno_sanitize_EQ : CommaJoined<["-"], "fno-sanitize=">, Group, - Flags<[CoreOption]>; + Flags<[CoreOption, DriverOption]>; def fsanitize_blacklist : Joined<["-"], "fsanitize-blacklist=">, - Group, Flags<[CC1Option, CoreOption]>, + Group, HelpText<"Path to blacklist file for sanitizers">; def fno_sanitize_blacklist : Flag<["-"], "fno-sanitize-blacklist">, Group, HelpText<"Don't use blacklist file for sanitizers">; def fsanitize_coverage : CommaJoined<["-"], "fsanitize-coverage=">, - Group, Flags<[CoreOption]>, + Group, HelpText<"Specify the type of coverage instrumentation for Sanitizers">; def fno_sanitize_coverage : CommaJoined<["-"], "fno-sanitize-coverage=">, - Group, Flags<[CoreOption]>, + Group, Flags<[CoreOption, DriverOption]>, HelpText<"Disable specified features of coverage instrumentation for " "Sanitizers">; def fsanitize_memory_track_origins_EQ : Joined<["-"], "fsanitize-memory-track-origins=">, - Group, Flags<[CC1Option]>, + Group, HelpText<"Enable origins tracking in MemorySanitizer">; def fsanitize_memory_track_origins : Flag<["-"], "fsanitize-memory-track-origins">, - Group, Flags<[CC1Option]>, + Group, HelpText<"Enable origins tracking in MemorySanitizer">; def fno_sanitize_memory_track_origins : Flag<["-"], "fno-sanitize-memory-track-origins">, - Group, Flags<[CC1Option]>, + Group, + Flags<[CoreOption, DriverOption]>, HelpText<"Disable origins tracking in MemorySanitizer">; def fsanitize_memory_use_after_dtor : Flag<["-"], "fsanitize-memory-use-after-dtor">, - Group, Flags<[CC1Option]>, + Group, HelpText<"Enable use-after-destroy detection in MemorySanitizer">; def fsanitize_address_field_padding : Joined<["-"], "fsanitize-address-field-padding=">, - Group, Flags<[CC1Option]>, + Group, HelpText<"Level of field padding for AddressSanitizer">; def fsanitize_address_use_after_scope : Flag<["-"], "fsanitize-address-use-after-scope">, - Group, Flags<[CC1Option]>, + Group, HelpText<"Enable use-after-scope detection in AddressSanitizer">; def fno_sanitize_address_use_after_scope : Flag<["-"], "fno-sanitize-address-use-after-scope">, - Group, Flags<[CC1Option]>, + Group, + Flags<[CoreOption, DriverOption]>, HelpText<"Disable use-after-scope detection in AddressSanitizer">; -def fsanitize_recover : Flag<["-"], "fsanitize-recover">, Group, - Flags<[CoreOption]>; +def fsanitize_recover : Flag<["-"], "fsanitize-recover">, Group; def fno_sanitize_recover : Flag<["-"], "fno-sanitize-recover">, - Group, Flags<[CoreOption]>; + Flags<[CoreOption, DriverOption]>, + Group; def fsanitize_recover_EQ : CommaJoined<["-"], "fsanitize-recover=">, Group, - Flags<[CC1Option, CoreOption]>, HelpText<"Enable recovery for specified sanitizers">; def fno_sanitize_recover_EQ : CommaJoined<["-"], "fno-sanitize-recover=">, - Group, Flags<[CoreOption]>, + Group, + Flags<[CoreOption, DriverOption]>, HelpText<"Disable recovery for specified sanitizers">; def fsanitize_trap_EQ : CommaJoined<["-"], "fsanitize-trap=">, Group, - Flags<[CC1Option, CoreOption]>, HelpText<"Enable trapping for specified sanitizers">; def fno_sanitize_trap_EQ : CommaJoined<["-"], "fno-sanitize-trap=">, Group, - Flags<[CoreOption]>, + Flags<[CoreOption, DriverOption]>, HelpText<"Disable trapping for specified sanitizers">; def fsanitize_undefined_trap_on_error : Flag<["-"], "fsanitize-undefined-trap-on-error">, Group; @@ -845,39 +851,47 @@ def fno_sanitize_undefined_trap_on_error : Flag<["-"], "fno-sanitize-undefined-t def fsanitize_link_cxx_runtime : Flag<["-"], "fsanitize-link-c++-runtime">, Group; def fsanitize_cfi_cross_dso : Flag<["-"], "fsanitize-cfi-cross-dso">, - Group, Flags<[CC1Option]>, + Group, HelpText<"Enable control flow integrity (CFI) checks for cross-DSO calls.">; def fno_sanitize_cfi_cross_dso : Flag<["-"], "fno-sanitize-cfi-cross-dso">, - Group, Flags<[CC1Option]>, + Flags<[CoreOption, DriverOption]>, + Group, HelpText<"Disable control flow integrity (CFI) checks for cross-DSO calls.">; def fsanitize_stats : Flag<["-"], "fsanitize-stats">, - Group, Flags<[CC1Option]>, + Group, HelpText<"Enable sanitizer statistics gathering.">; def fno_sanitize_stats : Flag<["-"], "fno-sanitize-stats">, - Group, Flags<[CC1Option]>, + Group, + Flags<[CoreOption, DriverOption]>, HelpText<"Disable sanitizer statistics gathering.">; def fsanitize_thread_memory_access : Flag<["-"], "fsanitize-thread-memory-access">, Group, HelpText<"Enable memory access instrumentation in ThreadSanitizer (default)">; def fno_sanitize_thread_memory_access : Flag<["-"], "fno-sanitize-thread-memory-access">, Group, + Flags<[CoreOption, DriverOption]>, HelpText<"Disable memory access instrumentation in ThreadSanitizer">; def fsanitize_thread_func_entry_exit : Flag<["-"], "fsanitize-thread-func-entry-exit">, Group, HelpText<"Enable function entry/exit instrumentation in ThreadSanitizer (default)">; def fno_sanitize_thread_func_entry_exit : Flag<["-"], "fno-sanitize-thread-func-entry-exit">, Group, + Flags<[CoreOption, DriverOption]>, HelpText<"Disable function entry/exit instrumentation in ThreadSanitizer">; def fsanitize_thread_atomics : Flag<["-"], "fsanitize-thread-atomics">, Group, HelpText<"Enable atomic operations instrumentation in ThreadSanitizer (default)">; def fno_sanitize_thread_atomics : Flag<["-"], "fno-sanitize-thread-atomics">, Group, + Flags<[CoreOption, DriverOption]>, HelpText<"Disable atomic operations instrumentation in ThreadSanitizer">; def fsanitize_undefined_strip_path_components_EQ : Joined<["-"], "fsanitize-undefined-strip-path-components=">, - Group, Flags<[CC1Option]>, MetaVarName<"">, + Group, MetaVarName<"">, HelpText<"Strip (or keep only, if negative) a given number of path components " "when emitting check metadata.">; + +} // end -f[no-]sanitize* flags + def funsafe_math_optimizations : Flag<["-"], "funsafe-math-optimizations">, Group; def fno_unsafe_math_optimizations : Flag<["-"], "fno-unsafe-math-optimizations">, diff --git a/test/Driver/fsanitize.c b/test/Driver/fsanitize.c index 4502f10b74..5cdc519f8d 100644 --- a/test/Driver/fsanitize.c +++ b/test/Driver/fsanitize.c @@ -109,12 +109,15 @@ // CHECK-SANE-SANKA: '-fsanitize=efficiency-{{.*}}' not allowed with '-fsanitize=kernel-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 +// RUN: %clang_cl -target x86_64-windows -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 -fno-sanitize-address-use-after-scope %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-USE-AFTER-SCOPE-OFF +// RUN: %clang_cl -target x86_64-windows -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 +// RUN: %clang_cl -target x86_64-windows -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 -- 2.40.0