[flang-commits] [flang] 6ba2c28 - [flang] Use std::clamp (NFC)

Kazu Hirata via flang-commits flang-commits at lists.llvm.org
Sat Aug 27 23:54:44 PDT 2022


Author: Kazu Hirata
Date: 2022-08-27T23:54:27-07:00
New Revision: 6ba2c28dee45cb349d882b2fdc2d3769fc901f58

URL: https://github.com/llvm/llvm-project/commit/6ba2c28dee45cb349d882b2fdc2d3769fc901f58
DIFF: https://github.com/llvm/llvm-project/commit/6ba2c28dee45cb349d882b2fdc2d3769fc901f58.diff

LOG: [flang] Use std::clamp (NFC)

The use of std::clamp here is safe because the definition of
largestLDKind gurantees that 8 <= largestLDKind.

Added: 
    

Modified: 
    flang/runtime/extrema.cpp

Removed: 
    


################################################################################
diff  --git a/flang/runtime/extrema.cpp b/flang/runtime/extrema.cpp
index d77ee17451d2e..1e7c364c27de7 100644
--- a/flang/runtime/extrema.cpp
+++ b/flang/runtime/extrema.cpp
@@ -629,8 +629,8 @@ template <int KIND> class Norm2Accumulator {
     8
 #endif
   };
-  using AccumType = CppTypeFor<TypeCategory::Real,
-      std::max(std::min(largestLDKind, KIND), 8)>;
+  using AccumType =
+      CppTypeFor<TypeCategory::Real, std::clamp(KIND, 8, largestLDKind)>;
   explicit Norm2Accumulator(const Descriptor &array) : array_{array} {}
   void Reinitialize() { max_ = sum_ = 0; }
   template <typename A> void GetResult(A *p, int /*zeroBasedDim*/ = -1) const {


        


More information about the flang-commits mailing list