[compiler-rt] r231151 - [UBSan] Add testcases for -fsanitize=shift-base and -fsanitize=shift-exponent.

Renato Golin renato.golin at linaro.org
Thu Mar 5 11:56:41 PST 2015


Hi Alexey,

Not sure you saw this, but this commit actually breaks AArch64 bots:

http://lab.llvm.org:8011/builders/clang-native-aarch64-full/builds/485/steps/ninja%20check%201/logs/UBSan-Standalone-aarch64%3A%3Ashift.cpp

cheers,
--renato

On 3 March 2015 at 22:15, Alexey Samsonov <vonosmas at gmail.com> wrote:
> Author: samsonov
> Date: Tue Mar  3 16:15:44 2015
> New Revision: 231151
>
> URL: http://llvm.org/viewvc/llvm-project?rev=231151&view=rev
> Log:
> [UBSan] Add testcases for -fsanitize=shift-base and -fsanitize=shift-exponent.
>
> Modified:
>     compiler-rt/trunk/test/ubsan/TestCases/Integer/shift.cpp
>     compiler-rt/trunk/test/ubsan/TestCases/Misc/coverage-levels.cc
>
> Modified: compiler-rt/trunk/test/ubsan/TestCases/Integer/shift.cpp
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Integer/shift.cpp?rev=231151&r1=231150&r2=231151&view=diff
> ==============================================================================
> --- compiler-rt/trunk/test/ubsan/TestCases/Integer/shift.cpp (original)
> +++ compiler-rt/trunk/test/ubsan/TestCases/Integer/shift.cpp Tue Mar  3 16:15:44 2015
> @@ -1,13 +1,20 @@
> -// RUN: %clangxx -DLSH_OVERFLOW -DOP='<<' -fsanitize=shift %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-LSH_OVERFLOW
> -// RUN: %clangxx -DLSH_OVERFLOW -DOP='<<=' -fsanitize=shift %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-LSH_OVERFLOW
> -// RUN: %clangxx -DTOO_LOW -DOP='<<' -fsanitize=shift %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
> -// RUN: %clangxx -DTOO_LOW -DOP='>>' -fsanitize=shift %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
> -// RUN: %clangxx -DTOO_LOW -DOP='<<=' -fsanitize=shift %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
> -// RUN: %clangxx -DTOO_LOW -DOP='>>=' -fsanitize=shift %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
> -// RUN: %clangxx -DTOO_HIGH -DOP='<<' -fsanitize=shift %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
> -// RUN: %clangxx -DTOO_HIGH -DOP='>>' -fsanitize=shift %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
> -// RUN: %clangxx -DTOO_HIGH -DOP='<<=' -fsanitize=shift %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
> -// RUN: %clangxx -DTOO_HIGH -DOP='>>=' -fsanitize=shift %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
> +// RUN: %clangxx -DLSH_OVERFLOW -DOP='<<' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-LSH_OVERFLOW
> +// RUN: %clangxx -DLSH_OVERFLOW -DOP='<<=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-LSH_OVERFLOW
> +// RUN: %clangxx -DTOO_LOW -DOP='<<' -fsanitize=shift-exponent -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
> +// RUN: %clangxx -DTOO_LOW -DOP='>>' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
> +// RUN: %clangxx -DTOO_LOW -DOP='<<=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
> +// RUN: %clangxx -DTOO_LOW -DOP='>>=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
> +// RUN: %clangxx -DTOO_HIGH -DOP='<<' -fsanitize=shift-exponent -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
> +// RUN: %clangxx -DTOO_HIGH -DOP='>>' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
> +// RUN: %clangxx -DTOO_HIGH -DOP='<<=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
> +// RUN: %clangxx -DTOO_HIGH -DOP='>>=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
> +
> +// RUN: %clangxx -DLSH_OVERFLOW -DOP='<<' -fsanitize=shift-exponent -fno-sanitize-recover=shift %s -o %t && %run %t
> +// RUN: %clangxx -DLSH_OVERFLOW -DOP='>>' -fsanitize=shift-exponent -fno-sanitize-recover=shift %s -o %t && %run %t
> +// RUN: %clangxx -DTOO_LOW -DOP='<<' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t && %run %t
> +// RUN: %clangxx -DTOO_LOW -DOP='>>' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t && %run %t
> +// RUN: %clangxx -DTOO_HIGH -DOP='<<' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t && %run %t
> +// RUN: %clangxx -DTOO_HIGH -DOP='>>' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t && %run %t
>
>  #include <stdint.h>
>
> @@ -20,18 +27,19 @@ int main() {
>    b <<= 1; // still ok, unsigned
>
>  #ifdef LSH_OVERFLOW
> -  // CHECK-LSH_OVERFLOW: shift.cpp:24:5: runtime error: left shift of negative value -2147483648
> +  // CHECK-LSH_OVERFLOW: shift.cpp:[[@LINE+1]]:5: runtime error: left shift of negative value -2147483648
>    a OP 1;
>  #endif
>
>  #ifdef TOO_LOW
> -  // CHECK-TOO_LOW: shift.cpp:29:5: runtime error: shift exponent -3 is negative
> +  a = 0;
> +  // CHECK-TOO_LOW: shift.cpp:[[@LINE+1]]:5: runtime error: shift exponent -3 is negative
>    a OP (-3);
>  #endif
>
>  #ifdef TOO_HIGH
>    a = 0;
> -  // CHECK-TOO_HIGH: shift.cpp:35:5: runtime error: shift exponent 32 is too large for 32-bit type 'int'
> +  // CHECK-TOO_HIGH: shift.cpp:[[@LINE+1]]:5: runtime error: shift exponent 32 is too large for 32-bit type 'int'
>    a OP 32;
>  #endif
>  }
>
> Modified: compiler-rt/trunk/test/ubsan/TestCases/Misc/coverage-levels.cc
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Misc/coverage-levels.cc?rev=231151&r1=231150&r2=231151&view=diff
> ==============================================================================
> --- compiler-rt/trunk/test/ubsan/TestCases/Misc/coverage-levels.cc (original)
> +++ compiler-rt/trunk/test/ubsan/TestCases/Misc/coverage-levels.cc Tue Mar  3 16:15:44 2015
> @@ -35,4 +35,4 @@ int main(int argc, char **argv) {
>  // to dump coverage.
>  // CHECK1:  1 PCs written
>  // CHECK2:  3 PCs written
> -// CHECK3:  4 PCs written
> +// CHECK3:  3 PCs written
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list