[PATCH] D48660: [UBSan] Add silence_unsigned_overflow flag.

Filipe Cabecinhas via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 29 07:45:22 PDT 2018


Why create yet another way to disable the printing of warnings?
Why not use the suppressions mechanism which is already there?

Thank you,
 Filipe

On Wed, Jun 27, 2018 at 7:29 PM, Matt Morehouse via Phabricator via
llvm-commits <llvm-commits at lists.llvm.org> wrote:
> This revision was automatically updated to reflect the committed changes.
> Closed by commit rCRT335762: [UBSan] Add silence_unsigned_overflow flag. (authored by morehouse, committed by ).
> Herald added a subscriber: Sanitizers.
>
> Changed prior to commit:
>   https://reviews.llvm.org/D48660?vs=153139&id=153141#toc
>
> Repository:
>   rCRT Compiler Runtime
>
> https://reviews.llvm.org/D48660
>
> Files:
>   lib/ubsan/ubsan_flags.inc
>   lib/ubsan/ubsan_handlers.cc
>   test/ubsan/TestCases/Integer/no-recover.cpp
>
>
> Index: lib/ubsan/ubsan_flags.inc
> ===================================================================
> --- lib/ubsan/ubsan_flags.inc
> +++ lib/ubsan/ubsan_flags.inc
> @@ -24,3 +24,6 @@
>  UBSAN_FLAG(const char *, suppressions, "", "Suppressions file name.")
>  UBSAN_FLAG(bool, report_error_type, false,
>          "Print specific error type instead of 'undefined-behavior' in summary.")
> +UBSAN_FLAG(bool, silence_unsigned_overflow, false,
> +       "Do not print error reports for unsigned integer overflow. "
> +       "Used to provide fuzzing signal without blowing up logs.")
> Index: lib/ubsan/ubsan_handlers.cc
> ===================================================================
> --- lib/ubsan/ubsan_handlers.cc
> +++ lib/ubsan/ubsan_handlers.cc
> @@ -15,6 +15,7 @@
>  #if CAN_SANITIZE_UB
>  #include "ubsan_handlers.h"
>  #include "ubsan_diag.h"
> +#include "ubsan_flags.h"
>  #include "ubsan_monitor.h"
>
>  #include "sanitizer_common/sanitizer_common.h"
> @@ -118,6 +119,9 @@
>    if (ignoreReport(Loc, Opts, ET))
>      return;
>
> +  if (!IsSigned && flags()->silence_unsigned_overflow)
> +    return;
> +
>    ScopedReport R(Opts, Loc, ET);
>
>    Diag(Loc, DL_Error, ET, "%0 integer overflow: "
> Index: test/ubsan/TestCases/Integer/no-recover.cpp
> ===================================================================
> --- test/ubsan/TestCases/Integer/no-recover.cpp
> +++ test/ubsan/TestCases/Integer/no-recover.cpp
> @@ -1,5 +1,6 @@
>  // RUN: %clangxx -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=RECOVER
>  // RUN: %clangxx -fsanitize=unsigned-integer-overflow -fno-sanitize-recover=all -fsanitize-recover=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=RECOVER
> +// RUN: %env_ubsan_opts=silence_unsigned_overflow=1 %run %t 2>&1 | FileCheck %s --check-prefix=SILENT-RECOVER --allow-empty
>  // RUN: %clangxx -fsanitize=unsigned-integer-overflow -fno-sanitize-recover=unsigned-integer-overflow %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=ABORT
>
>  #include <stdint.h>
> @@ -18,5 +19,6 @@
>
>    (void)(uint64_t(10000000000000000000ull) + uint64_t(9000000000000000000ull));
>    // RECOVER: 10000000000000000000 + 9000000000000000000 cannot be represented in type 'unsigned {{long( long)?}}'
> +  // SILENT-RECOVER-NOT: runtime error
>    // ABORT-NOT: runtime error
>  }
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>


More information about the llvm-commits mailing list