[clang] [HIP] fix host min/max in header (PR #82956)

via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 25 20:01:05 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 8be39b3901e3326ceebeaf0381f8cc57fdc0d464 e36760486cc794dd3dc1604b0969b83f25bdd757 -- clang/lib/Headers/__clang_hip_math.h
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/Headers/__clang_hip_math.h b/clang/lib/Headers/__clang_hip_math.h
index e87070e41b..dc4df40101 100644
--- a/clang/lib/Headers/__clang_hip_math.h
+++ b/clang/lib/Headers/__clang_hip_math.h
@@ -1311,15 +1311,15 @@ double min(double __x, double __y) { return __builtin_fmin(__x, __y); }
 #if !defined(__HIPCC_RTC__) && !defined(__OPENMP_AMDGCN__)
 
 #pragma push_macro("DEFINE_MIN_MAX_FUNCTIONS")
-#define DEFINE_MIN_MAX_FUNCTIONS(type1, type2) \
-static inline auto min(const type1 __a, const type2 __b) \
-  -> typename std::remove_reference<decltype(__a < __b ? __a : __b)>::type { \
-  return (__a < __b) ? __a : __b; \
-} \
-static inline auto max(const type1 __a, const type2 __b) \
-  -> typename std::remove_reference<decltype(__a > __b ? __a : __b)>::type { \
-  return (__a > __b) ? __a : __b; \
-}
+#define DEFINE_MIN_MAX_FUNCTIONS(type1, type2)                                 \
+  static inline auto min(const type1 __a, const type2 __b) ->                  \
+      typename std::remove_reference<decltype(__a < __b ? __a : __b)>::type {  \
+    return (__a < __b) ? __a : __b;                                            \
+  }                                                                            \
+  static inline auto max(const type1 __a, const type2 __b) ->                  \
+      typename std::remove_reference<decltype(__a > __b ? __a : __b)>::type {  \
+    return (__a > __b) ? __a : __b;                                            \
+  }
 
 // Define min and max functions for same type comparisons
 DEFINE_MIN_MAX_FUNCTIONS(int, int)
@@ -1338,15 +1338,31 @@ DEFINE_MIN_MAX_FUNCTIONS(long long, unsigned long long)
 DEFINE_MIN_MAX_FUNCTIONS(unsigned long long, long long)
 
 // Floating-point comparisons using built-in functions
-static inline float min(float const __a, float const __b) { return __builtin_fminf(__a, __b); }
-static inline double min(double const __a, double const __b) { return __builtin_fmin(__a, __b); }
-static inline double min(float const __a, double const __b) { return __builtin_fmin(__a, __b); }
-static inline double min(double const __a, float const __b) { return __builtin_fmin(__a, __b); }
-
-static inline float max(float const __a, float const __b) { return __builtin_fmaxf(__a, __b); }
-static inline double max(double const __a, double const __b) { return __builtin_fmax(__a, __b); }
-static inline double max(float const __a, double const __b) { return __builtin_fmax(__a, __b); }
-static inline double max(double const __a, float const __b) { return __builtin_fmax(__a, __b); }
+static inline float min(float const __a, float const __b) {
+  return __builtin_fminf(__a, __b);
+}
+static inline double min(double const __a, double const __b) {
+  return __builtin_fmin(__a, __b);
+}
+static inline double min(float const __a, double const __b) {
+  return __builtin_fmin(__a, __b);
+}
+static inline double min(double const __a, float const __b) {
+  return __builtin_fmin(__a, __b);
+}
+
+static inline float max(float const __a, float const __b) {
+  return __builtin_fmaxf(__a, __b);
+}
+static inline double max(double const __a, double const __b) {
+  return __builtin_fmax(__a, __b);
+}
+static inline double max(float const __a, double const __b) {
+  return __builtin_fmax(__a, __b);
+}
+static inline double max(double const __a, float const __b) {
+  return __builtin_fmax(__a, __b);
+}
 
 #pragma pop_macro("DEFINE_MIN_MAX_FUNCTIONS")
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/82956


More information about the cfe-commits mailing list