[llvm] 63f08a5 - [APInt] Fix implicit truncation warning in bitsToFloat(). NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 6 04:30:31 PST 2019


Author: Simon Pilgrim
Date: 2019-11-06T12:30:04Z
New Revision: 63f08a59c8942e99d71cfef21cfc050b6f3d6d52

URL: https://github.com/llvm/llvm-project/commit/63f08a59c8942e99d71cfef21cfc050b6f3d6d52
DIFF: https://github.com/llvm/llvm-project/commit/63f08a59c8942e99d71cfef21cfc050b6f3d6d52.diff

LOG: [APInt] Fix implicit truncation warning in bitsToFloat(). NFCI.

Added: 
    

Modified: 
    llvm/include/llvm/ADT/APInt.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index 07b2e80099e6..6e611ad3fd32 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -1727,13 +1727,13 @@ class LLVM_NODISCARD APInt {
     return BitsToDouble(getWord(0));
   }
 
-  /// Converts APInt bits to a double
+  /// Converts APInt bits to a float
   ///
   /// The conversion does not do a translation from integer to float, it just
   /// re-interprets the bits as a float. Note that it is valid to do this on
   /// any bit width. Exactly 32 bits will be translated.
   float bitsToFloat() const {
-    return BitsToFloat(getWord(0));
+    return BitsToFloat(static_cast<uint32_t>(getWord(0)));
   }
 
   /// Converts a double to APInt bits.


        


More information about the llvm-commits mailing list