[Lldb-commits] [lldb] 15ee8a3 - Silence warnings around int/float conversions.

Eric Christopher via lldb-commits lldb-commits at lists.llvm.org
Tue May 19 10:56:38 PDT 2020


Author: Eric Christopher
Date: 2020-05-19T10:56:18-07:00
New Revision: 15ee8a3a58223b48afbe33cb60084f864ef20889

URL: https://github.com/llvm/llvm-project/commit/15ee8a3a58223b48afbe33cb60084f864ef20889
DIFF: https://github.com/llvm/llvm-project/commit/15ee8a3a58223b48afbe33cb60084f864ef20889.diff

LOG: Silence warnings around int/float conversions.

Added: 
    

Modified: 
    lldb/source/Plugins/Language/ObjC/Cocoa.cpp
    lldb/unittests/DataFormatter/MockTests.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
index 1ad443b8b74e..37b352263260 100644
--- a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
+++ b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
@@ -794,8 +794,8 @@ bool lldb_private::formatters::NSDate::FormatDateValue(double date_value,
     return true;
   }
 
-  if (date_value > std::numeric_limits<time_t>::max() ||
-      date_value < std::numeric_limits<time_t>::min())
+  if ((time_t)date_value > std::numeric_limits<time_t>::max() ||
+      (time_t)date_value < std::numeric_limits<time_t>::min())
     return false;
 
   time_t epoch = GetOSXEpoch();

diff  --git a/lldb/unittests/DataFormatter/MockTests.cpp b/lldb/unittests/DataFormatter/MockTests.cpp
index 1185d7bf2c9c..f7daaf22d140 100644
--- a/lldb/unittests/DataFormatter/MockTests.cpp
+++ b/lldb/unittests/DataFormatter/MockTests.cpp
@@ -28,14 +28,14 @@ TEST(DataFormatterMockTest, NSDate) {
   EXPECT_EQ(*formatDateValue(-63114076800), "0001-12-30 00:00:00 +0000");
 
   // Can't convert the date_value to a time_t.
-  EXPECT_EQ(formatDateValue(std::numeric_limits<time_t>::max() + 1),
+  EXPECT_EQ(formatDateValue((double)(std::numeric_limits<time_t>::max()) + 1),
             llvm::None);
-  EXPECT_EQ(formatDateValue(std::numeric_limits<time_t>::min() - 1),
+  EXPECT_EQ(formatDateValue((double)(std::numeric_limits<time_t>::min()) - 1),
             llvm::None);
 
   // Can't add the macOS epoch to the converted date_value (the add overflows).
-  EXPECT_EQ(formatDateValue(std::numeric_limits<time_t>::max()), llvm::None);
-  EXPECT_EQ(formatDateValue(std::numeric_limits<time_t>::min()), llvm::None);
+  EXPECT_EQ(formatDateValue((double)std::numeric_limits<time_t>::max()), llvm::None);
+  EXPECT_EQ(formatDateValue((double)std::numeric_limits<time_t>::min()), llvm::None);
 
   // FIXME: The formatting result is wrong on Windows because we adjust the
   // epoch when _WIN32 is defined (see GetOSXEpoch).


        


More information about the lldb-commits mailing list