diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2018-10-11 09:09:52 +0000 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2018-10-11 09:09:52 +0000 |
commit | d32c0d1466de85f68b82cbb500d04dcedf95984f (patch) | |
tree | fd17c6c2f740c36b16b76dcd5073fc18c9bda94d /compiler-rt/test/ubsan_minimal | |
parent | dd403575a2e2068fd278a6165bc199b037759e6b (diff) | |
download | bcm5719-llvm-d32c0d1466de85f68b82cbb500d04dcedf95984f.tar.gz bcm5719-llvm-d32c0d1466de85f68b82cbb500d04dcedf95984f.zip |
[compiler-rt][ubsan] Split Implicit Integer Truncation Sanitizer into unsigned and signed checks
Summary:
This is compiler-rt part.
clang part is D50901.
Reviewers: rsmith, vsk, filcab, Sanitizers
Reviewed by: filcab
Differential Revision: https://reviews.llvm.org/D50902
llvm-svn: 344231
Diffstat (limited to 'compiler-rt/test/ubsan_minimal')
-rw-r--r-- | compiler-rt/test/ubsan_minimal/TestCases/implicit-signed-integer-truncation.c | 25 | ||||
-rw-r--r-- | compiler-rt/test/ubsan_minimal/TestCases/implicit-unsigned-integer-truncation.c (renamed from compiler-rt/test/ubsan_minimal/TestCases/implicit-integer-truncation.c) | 2 |
2 files changed, 26 insertions, 1 deletions
diff --git a/compiler-rt/test/ubsan_minimal/TestCases/implicit-signed-integer-truncation.c b/compiler-rt/test/ubsan_minimal/TestCases/implicit-signed-integer-truncation.c new file mode 100644 index 00000000000..9677407e0ce --- /dev/null +++ b/compiler-rt/test/ubsan_minimal/TestCases/implicit-signed-integer-truncation.c @@ -0,0 +1,25 @@ +// RUN: %clang -fsanitize=implicit-signed-integer-truncation %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK + +#include <stdint.h> + +int main() { +// CHECK-NOT: implicit-conversion + + // Negative tests. Even if they produce unexpected results, this sanitizer does not care. + int8_t n0 = (~((uint32_t)(0))); // ~0 -> -1, but do not warn. + uint8_t n2 = 128; + uint8_t n3 = 255; + // Bools do not count + _Bool b0 = (~((uint32_t)(0))); + _Bool b1 = 255; + + // Explicit and-ing of bits will silence it. + uint8_t nc0 = ((int32_t)(-1)) & 255; + + // Positive tests. + uint8_t t0 = (int32_t)(-1); +// CHECK: implicit-conversion +// CHECK-NOT: implicit-conversion + + return 0; +} diff --git a/compiler-rt/test/ubsan_minimal/TestCases/implicit-integer-truncation.c b/compiler-rt/test/ubsan_minimal/TestCases/implicit-unsigned-integer-truncation.c index 28711d2eeda..8b9e166af81 100644 --- a/compiler-rt/test/ubsan_minimal/TestCases/implicit-integer-truncation.c +++ b/compiler-rt/test/ubsan_minimal/TestCases/implicit-unsigned-integer-truncation.c @@ -1,4 +1,4 @@ -// RUN: %clang -fsanitize=implicit-integer-truncation %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK +// RUN: %clang -fsanitize=implicit-unsigned-integer-truncation %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK #include <stdint.h> |