[compiler-rt] r209516 - [ubsan] handle long double in 32-bit mode; part of the patch by Marek Polacek
Kostya Serebryany
kcc at google.com
Fri May 23 07:45:14 PDT 2014
Author: kcc
Date: Fri May 23 09:45:13 2014
New Revision: 209516
URL: http://llvm.org/viewvc/llvm-project?rev=209516&view=rev
Log:
[ubsan] handle long double in 32-bit mode; part of the patch by Marek Polacek
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors_format.inc
compiler-rt/trunk/lib/ubsan/ubsan_value.cc
compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors_format.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors_format.inc?rev=209516&r1=209515&r2=209516&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors_format.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors_format.inc Fri May 23 09:45:13 2014
@@ -459,6 +459,9 @@ static int printf_get_value_size(PrintfD
case 8: \
va_arg(*aq, double); \
break; \
+ case 12: \
+ va_arg(*aq, long double); \
+ break; \
case 16: \
va_arg(*aq, long double); \
break; \
Modified: compiler-rt/trunk/lib/ubsan/ubsan_value.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/ubsan_value.cc?rev=209516&r1=209515&r2=209516&view=diff
==============================================================================
--- compiler-rt/trunk/lib/ubsan/ubsan_value.cc (original)
+++ compiler-rt/trunk/lib/ubsan/ubsan_value.cc Fri May 23 09:45:13 2014
@@ -94,6 +94,7 @@ FloatMax Value::getFloatValue() const {
switch (getType().getFloatBitWidth()) {
case 64: return *reinterpret_cast<double*>(Val);
case 80: return *reinterpret_cast<long double*>(Val);
+ case 96: return *reinterpret_cast<long double*>(Val);
case 128: return *reinterpret_cast<long double*>(Val);
}
}
Modified: compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp?rev=209516&r1=209515&r2=209516&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp (original)
+++ compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp Fri May 23 09:45:13 2014
@@ -9,6 +9,21 @@
// RUN: %run %t 6 2>&1 | FileCheck %s --check-prefix=CHECK-6
// FIXME: %run %t 7 2>&1 | FileCheck %s --check-prefix=CHECK-7
// RUN: %run %t 8 2>&1 | FileCheck %s --check-prefix=CHECK-8
+// RUN: %run %t 9 2>&1 | FileCheck %s --check-prefix=CHECK-9
+
+// FIXME: run all ubsan tests in 32- and 64-bit modes (?).
+// RUN: %clangxx -fsanitize=float-cast-overflow -m32 %s -o %t
+// RUN: %run %t _
+// RUN: %run %t 0 2>&1 | FileCheck %s --check-prefix=CHECK-0
+// RUN: %run %t 1 2>&1 | FileCheck %s --check-prefix=CHECK-1
+// RUN: %run %t 2 2>&1 | FileCheck %s --check-prefix=CHECK-2
+// RUN: %run %t 3 2>&1 | FileCheck %s --check-prefix=CHECK-3
+// RUN: %run %t 4 2>&1 | FileCheck %s --check-prefix=CHECK-4
+// RUN: %run %t 5 2>&1 | FileCheck %s --check-prefix=CHECK-5
+// RUN: %run %t 6 2>&1 | FileCheck %s --check-prefix=CHECK-6
+// FIXME: %run %t 7 2>&1 | FileCheck %s --check-prefix=CHECK-7
+// RUN: %run %t 8 2>&1 | FileCheck %s --check-prefix=CHECK-8
+// RUN: %run %t 9 2>&1 | FileCheck %s --check-prefix=CHECK-9
// This test assumes float and double are IEEE-754 single- and double-precision.
@@ -95,5 +110,10 @@ int main(int argc, char **argv) {
case '8':
// CHECK-8: runtime error: value 1e+39 is outside the range of representable values of type 'float'
return (float)1e39;
+ case '9':
+ volatile long double ld = 300.0;
+ // CHECK-9: runtime error: value 300 is outside the range of representable values of type 'char'
+ char c = ld;
+ return c;
}
}
More information about the llvm-commits
mailing list