Skip to content

Commit

Permalink
Silence warnings around int/float conversions.
Browse files Browse the repository at this point in the history
  • Loading branch information
echristo committed May 19, 2020
1 parent 225f241 commit 15ee8a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lldb/source/Plugins/Language/ObjC/Cocoa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions lldb/unittests/DataFormatter/MockTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

0 comments on commit 15ee8a3

Please sign in to comment.