Selaa lähdekoodia

Everywhere: Add Clang pragmas

We use these to prevent UB from being optimized away in `/bin/crash` and
to make the compiler not warn about the many implicit floating point
type promotions in LibM.
Daniel Bertalan 4 vuotta sitten
vanhempi
commit
e8e628de57
2 muutettua tiedostoa jossa 14 lisäystä ja 1 poistoa
  1. 9 0
      Userland/Libraries/LibM/math.cpp
  2. 5 1
      Userland/Utilities/crash.cpp

+ 9 - 0
Userland/Libraries/LibM/math.cpp

@@ -14,6 +14,11 @@
 #include <stdint.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <stdlib.h>
 
 
+#ifdef __clang__
+#    pragma clang diagnostic push
+#    pragma clang diagnostic ignored "-Wdouble-promotion"
+#endif
+
 template<size_t>
 template<size_t>
 constexpr double e_to_power();
 constexpr double e_to_power();
 template<>
 template<>
@@ -1461,3 +1466,7 @@ float nearbyintf(float value) NOEXCEPT
     return internal_to_integer(value, RoundingMode { fegetround() });
     return internal_to_integer(value, RoundingMode { fegetround() });
 }
 }
 }
 }
+
+#ifdef __clang__
+#    pragma clang diagnostic pop
+#endif

+ 5 - 1
Userland/Utilities/crash.cpp

@@ -21,7 +21,11 @@
 
 
 using Test::Crash;
 using Test::Crash;
 
 
-#pragma GCC optimize("O0")
+#ifdef __clang__
+#    pragma clang optimize off
+#else
+#    pragma GCC optimize("O0")
+#endif
 
 
 int main(int argc, char** argv)
 int main(int argc, char** argv)
 {
 {