[clang] 647e48c - [clang] Use std::clamp (NFC)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 16 10:11:39 PDT 2022


Author: Kazu Hirata
Date: 2022-10-16T10:11:29-07:00
New Revision: 647e48cf5f6094ad874766c1471410641b1b86bd

URL: https://github.com/llvm/llvm-project/commit/647e48cf5f6094ad874766c1471410641b1b86bd
DIFF: https://github.com/llvm/llvm-project/commit/647e48cf5f6094ad874766c1471410641b1b86bd.diff

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

Note that the constructor of MipsABIInfo guarantees that
MinABIStackAlignInBytes <= StackAlignInBytes, so we can use std::clamp
safely.

Added: 
    

Modified: 
    clang/lib/CodeGen/TargetInfo.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index 74997f0f9e9d..bfe0fbec2ad5 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -7845,7 +7845,7 @@ void MSP430TargetCodeGenInfo::setTargetAttributes(
 namespace {
 class MipsABIInfo : public ABIInfo {
   bool IsO32;
-  unsigned MinABIStackAlignInBytes, StackAlignInBytes;
+  const unsigned MinABIStackAlignInBytes, StackAlignInBytes;
   void CoerceToIntArgs(uint64_t TySize,
                        SmallVectorImpl<llvm::Type *> &ArgList) const;
   llvm::Type* HandleAggregates(QualType Ty, uint64_t TySize) const;
@@ -8022,8 +8022,8 @@ MipsABIInfo::classifyArgumentType(QualType Ty, uint64_t &Offset) const {
   uint64_t TySize = getContext().getTypeSize(Ty);
   uint64_t Align = getContext().getTypeAlign(Ty) / 8;
 
-  Align = std::min(std::max(Align, (uint64_t)MinABIStackAlignInBytes),
-                   (uint64_t)StackAlignInBytes);
+  Align = std::clamp(Align, (uint64_t)MinABIStackAlignInBytes,
+                     (uint64_t)StackAlignInBytes);
   unsigned CurrOffset = llvm::alignTo(Offset, Align);
   Offset = CurrOffset + llvm::alignTo(TySize, Align * 8) / 8;
 


        


More information about the cfe-commits mailing list