llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Thurston Dang (thurstond) <details> <summary>Changes</summary> For backwards compatibility, `parseSanitizeArgs`/`parseSanitizeTrapArgs` had an incomplete refactoring in https://github.com/llvm/llvm-project/pull/119819, in order to accommodate the special case of vptr in -fsanitize=undefined and its interaction with -fsanitize-trap=undefined. Now that vptr is no longer part of -fsanitize=undefined (https://github.com/llvm/llvm-project/pull/121115), this patch changes parseSanitizeArgs to apply the AlwaysIn/Out invariants in parseSanitizeArgs, which allows simplifying calls to parseSanitizeArgs. This is not quite NFC: it changes the error message of -fsanitize-trap=vptr. --- Full diff: https://github.com/llvm/llvm-project/pull/129405.diff 2 Files Affected: - (modified) clang/lib/Driver/SanitizerArgs.cpp (+4-10) - (modified) clang/test/Driver/fsanitize.c (+1-1) ``````````diff diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp index 6e75001585c61..f5b0bc5ce720f 100644 --- a/clang/lib/Driver/SanitizerArgs.cpp +++ b/clang/lib/Driver/SanitizerArgs.cpp @@ -261,11 +261,8 @@ static SanitizerMask setGroupBits(SanitizerMask Kinds) { } // Computes the sanitizer mask as: -// Default + Arguments (in or out) +// Default + Arguments (in or out) + AlwaysIn - AlwaysOut // with arguments parsed from left to right. -// -// Error messages are printed if the AlwaysIn or AlwaysOut invariants are -// violated, but the caller must enforce these invariants themselves. static SanitizerMask parseSanitizeArgs(const Driver &D, const llvm::opt::ArgList &Args, bool DiagnoseErrors, SanitizerMask Default, @@ -315,6 +312,9 @@ parseSanitizeArgs(const Driver &D, const llvm::opt::ArgList &Args, } } + Output |= AlwaysIn; + Output &= ~AlwaysOut; + return Output; } @@ -324,10 +324,6 @@ static SanitizerMask parseSanitizeTrapArgs(const Driver &D, SanitizerMask AlwaysTrap; // Empty SanitizerMask NeverTrap = ~(setGroupBits(TrappingSupported)); - // N.B. We do *not* enforce NeverTrap. This maintains the behavior of - // '-fsanitize=undefined -fsanitize-trap=undefined' - // (clang/test/Driver/fsanitize.c ), which is that vptr is not enabled at all - // (not even in recover mode) in order to avoid the need for a ubsan runtime. return parseSanitizeArgs(D, Args, DiagnoseErrors, TrappingDefault, AlwaysTrap, NeverTrap, options::OPT_fsanitize_trap_EQ, options::OPT_fno_sanitize_trap_EQ); @@ -725,8 +721,6 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC, D, Args, DiagnoseErrors, RecoverableByDefault, AlwaysRecoverable, Unrecoverable, options::OPT_fsanitize_recover_EQ, options::OPT_fno_sanitize_recover_EQ); - RecoverableKinds |= AlwaysRecoverable; - RecoverableKinds &= ~Unrecoverable; RecoverableKinds &= Kinds; TrappingKinds &= Kinds; diff --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c index 79c936a79ffd2..9eb6579ce30ab 100644 --- a/clang/test/Driver/fsanitize.c +++ b/clang/test/Driver/fsanitize.c @@ -149,7 +149,7 @@ // CHECK-FSANITIZE-SHIFT-PARTIAL: "-fsanitize=shift-exponent" // RUN: not %clang --target=x86_64-linux-gnu -fsanitize=vptr -fsanitize-trap=vptr %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-TRAP-UNDEF -// CHECK-VPTR-TRAP-UNDEF: error: invalid argument '-fsanitize=vptr' not allowed with '-fsanitize-trap=undefined' +// CHECK-VPTR-TRAP-UNDEF: error: unsupported argument 'vptr' to option '-fsanitize-trap=' // RUN: %clang --target=x86_64-linux-gnu -fsanitize=vptr -fsanitize-undefined-trap-on-error %s -### `````````` </details> https://github.com/llvm/llvm-project/pull/129405 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits