r373451 - Log2_32 returns an unsigned. NFCI.

Simon Pilgrim via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 2 04:49:32 PDT 2019


Author: rksimon
Date: Wed Oct  2 04:49:32 2019
New Revision: 373451

URL: http://llvm.org/viewvc/llvm-project?rev=373451&view=rev
Log:
Log2_32 returns an unsigned. NFCI.

Silences clang static analyzer warning about out of bounds (negative) shifts.

Modified:
    cfe/trunk/lib/CodeGen/CGObjCGNU.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=373451&r1=373450&r2=373451&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Wed Oct  2 04:49:32 2019
@@ -1854,7 +1854,8 @@ class CGObjCGNUstep2 : public CGObjCGNUs
         ivarBuilder.addInt(Int32Ty,
             CGM.getContext().getTypeSizeInChars(ivarTy).getQuantity());
         // Alignment will be stored as a base-2 log of the alignment.
-        int align = llvm::Log2_32(Context.getTypeAlignInChars(ivarTy).getQuantity());
+        unsigned align =
+            llvm::Log2_32(Context.getTypeAlignInChars(ivarTy).getQuantity());
         // Objects that require more than 2^64-byte alignment should be impossible!
         assert(align < 64);
         // uint32_t flags;




More information about the cfe-commits mailing list