-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[compiler-rt][ubsa] Reformat cast-overflow test. NFC #129662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alexander-shaposhnikov
merged 1 commit into
llvm:main
from
alexander-shaposhnikov:reformat_test
Mar 4, 2025
Merged
[compiler-rt][ubsa] Reformat cast-overflow test. NFC #129662
alexander-shaposhnikov
merged 1 commit into
llvm:main
from
alexander-shaposhnikov:reformat_test
Mar 4, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
|
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Alexander Shaposhnikov (alexander-shaposhnikov) ChangesReformat cast-overflow test. NFC Full diff: https://github.com/llvm/llvm-project/pull/129662.diff 1 Files Affected:
diff --git a/compiler-rt/test/ubsan/TestCases/Float/cast-overflow.cpp b/compiler-rt/test/ubsan/TestCases/Float/cast-overflow.cpp
index 859bc6a2fc9e7..3671770bbfa43 100644
--- a/compiler-rt/test/ubsan/TestCases/Float/cast-overflow.cpp
+++ b/compiler-rt/test/ubsan/TestCases/Float/cast-overflow.cpp
@@ -15,41 +15,41 @@
// This test assumes float and double are IEEE-754 single- and double-precision.
#if defined(__APPLE__)
-# include <machine/endian.h>
-# define BYTE_ORDER __DARWIN_BYTE_ORDER
-# define BIG_ENDIAN __DARWIN_BIG_ENDIAN
-# define LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN
+#include <machine/endian.h>
+#define BYTE_ORDER __DARWIN_BYTE_ORDER
+#define BIG_ENDIAN __DARWIN_BIG_ENDIAN
+#define LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN
#elif defined(__FreeBSD__) || defined(__NetBSD__)
-# include <sys/endian.h>
-# ifndef BYTE_ORDER
-# define BYTE_ORDER _BYTE_ORDER
-# endif
-# ifndef BIG_ENDIAN
-# define BIG_ENDIAN _BIG_ENDIAN
-# endif
-# ifndef LITTLE_ENDIAN
-# define LITTLE_ENDIAN _LITTLE_ENDIAN
-# endif
+#include <sys/endian.h>
+#ifndef BYTE_ORDER
+#define BYTE_ORDER _BYTE_ORDER
+#endif
+#ifndef BIG_ENDIAN
+#define BIG_ENDIAN _BIG_ENDIAN
+#endif
+#ifndef LITTLE_ENDIAN
+#define LITTLE_ENDIAN _LITTLE_ENDIAN
+#endif
#elif defined(__sun__) && defined(__svr4__)
// Solaris provides _BIG_ENDIAN/_LITTLE_ENDIAN selector in sys/types.h.
-# include <sys/types.h>
-# define BIG_ENDIAN 4321
-# define LITTLE_ENDIAN 1234
-# if defined(_BIG_ENDIAN)
-# define BYTE_ORDER BIG_ENDIAN
-# else
-# define BYTE_ORDER LITTLE_ENDIAN
-# endif
+#include <sys/types.h>
+#define BIG_ENDIAN 4321
+#define LITTLE_ENDIAN 1234
+#if defined(_BIG_ENDIAN)
+#define BYTE_ORDER BIG_ENDIAN
+#else
+#define BYTE_ORDER LITTLE_ENDIAN
+#endif
#elif defined(_WIN32)
-# define BYTE_ORDER 0
-# define BIG_ENDIAN 1
-# define LITTLE_ENDIAN 0
+#define BYTE_ORDER 0
+#define BIG_ENDIAN 1
+#define LITTLE_ENDIAN 0
#else
-# include <endian.h>
-# define BYTE_ORDER __BYTE_ORDER
-# define BIG_ENDIAN __BIG_ENDIAN
-# define LITTLE_ENDIAN __LITTLE_ENDIAN
-#endif // __APPLE__
+#include <endian.h>
+#define BYTE_ORDER __BYTE_ORDER
+#define BIG_ENDIAN __BIG_ENDIAN
+#define LITTLE_ENDIAN __LITTLE_ENDIAN
+#endif // __APPLE__
#include <stdint.h>
#include <stdio.h>
#include <string.h>
@@ -59,7 +59,7 @@ float NaN;
int main(int argc, char **argv) {
float MaxFloatRepresentableAsInt = 0x7fffff80;
- (int)MaxFloatRepresentableAsInt; // ok
+ (int)MaxFloatRepresentableAsInt; // ok
(int)-MaxFloatRepresentableAsInt; // ok
float MinFloatRepresentableAsInt = -0x7fffffff - 1;
@@ -78,18 +78,18 @@ int main(int argc, char **argv) {
// Build a '+Inf'.
#if BYTE_ORDER == LITTLE_ENDIAN
- unsigned char InfVal[] = { 0x00, 0x00, 0x80, 0x7f };
+ unsigned char InfVal[] = {0x00, 0x00, 0x80, 0x7f};
#else
- unsigned char InfVal[] = { 0x7f, 0x80, 0x00, 0x00 };
+ unsigned char InfVal[] = {0x7f, 0x80, 0x00, 0x00};
#endif
float Inf;
memcpy(&Inf, InfVal, 4);
// Build a 'NaN'.
#if BYTE_ORDER == LITTLE_ENDIAN
- unsigned char NaNVal[] = { 0x01, 0x00, 0x80, 0x7f };
+ unsigned char NaNVal[] = {0x01, 0x00, 0x80, 0x7f};
#else
- unsigned char NaNVal[] = { 0x7f, 0x80, 0x00, 0x01 };
+ unsigned char NaNVal[] = {0x7f, 0x80, 0x00, 0x01};
#endif
float NaN;
memcpy(&NaN, NaNVal, 4);
@@ -107,7 +107,7 @@ int main(int argc, char **argv) {
static int test_int = MaxFloatRepresentableAsInt + 0x80;
// CHECK-0: SUMMARY: {{.*}}Sanitizer: float-cast-overflow {{.*}}cast-overflow.cpp:[[@LINE-1]]
return 0;
- }
+ }
case '1': {
// CHECK-1: {{.*}}cast-overflow.cpp:[[@LINE+1]]:27: runtime error: -2.14748{{.*}} is outside the range of representable values of type 'int'
static int test_int = MinFloatRepresentableAsInt - 0x100;
@@ -135,16 +135,15 @@ int main(int argc, char **argv) {
static int test_int = NaN;
return 0;
}
-
- // Integer -> floating point overflow.
+ // Integer -> floating point overflow.
case '6': {
// CHECK-6: cast-overflow.cpp:[[@LINE+2]]:{{27: runtime error: 3.40282e\+38 is outside the range of representable values of type 'int'| __int128 not supported}}
#if defined(__SIZEOF_INT128__) && !defined(_WIN32)
static int test_int = (float)(FloatMaxAsUInt128 + 1);
return 0;
#else
- // Print the same line as the check above. That way the test is robust to
- // line changes around it
+ // Print the same line as the check above.
+ // That way the test is robust to line changes around it
printf("%s:%d: __int128 not supported", __FILE__, __LINE__ - 5);
return 0;
#endif
|
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
vitalybuka
approved these changes
Mar 4, 2025
Collaborator
|
It's still not happy |
Collaborator
|
|
682bbda to
0e88b36
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reformat cast-overflow test. NFC