summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Chrono.cpp
diff options
context:
space:
mode:
authorSimon Dardis <simon.dardis@mips.com>2017-11-06 23:01:46 +0000
committerSimon Dardis <simon.dardis@mips.com>2017-11-06 23:01:46 +0000
commit8bdbff37febe7a0d0f5c59fe3714c30f2d064a24 (patch)
treefdfdf9681fb0974fdd520347fd10ffc294464857 /llvm/lib/Support/Chrono.cpp
parent182f9fea37da694a25541af1dd03319091d4884f (diff)
downloadbcm5719-llvm-8bdbff37febe7a0d0f5c59fe3714c30f2d064a24.tar.gz
bcm5719-llvm-8bdbff37febe7a0d0f5c59fe3714c30f2d064a24.zip
[Support][Chrono] Use explicit cast of text output of time values.
rL316419 exposed a platform specific issue where the type of the values passed to llvm::format could be different to the format string. Debian unstable for mips uses long long int for std::chrono:duration, while x86_64 uses long int. For mips, this resulted in the value being corrupted when rendered to a string. Address this by explicitly casting the result of the duration_cast to the type specified in the format string. Reviewers: sammccall Differential Revision: https://reviews.llvm.org/D39597 llvm-svn: 317523
Diffstat (limited to 'llvm/lib/Support/Chrono.cpp')
-rw-r--r--llvm/lib/Support/Chrono.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/Support/Chrono.cpp b/llvm/lib/Support/Chrono.cpp
index a39b485bd13..84f5aab6fc4 100644
--- a/llvm/lib/Support/Chrono.cpp
+++ b/llvm/lib/Support/Chrono.cpp
@@ -65,17 +65,17 @@ void format_provider<TimePoint<>>::format(const TimePoint<> &T, raw_ostream &OS,
if (Style[I] == '%' && Style.size() > I + 1) switch (Style[I + 1]) {
case 'L': // Milliseconds, from Ruby.
FStream << llvm::format(
- "%.3lu", duration_cast<milliseconds>(Fractional).count());
+ "%.3lu", (long)duration_cast<milliseconds>(Fractional).count());
++I;
continue;
case 'f': // Microseconds, from Python.
FStream << llvm::format(
- "%.6lu", duration_cast<microseconds>(Fractional).count());
+ "%.6lu", (long)duration_cast<microseconds>(Fractional).count());
++I;
continue;
case 'N': // Nanoseconds, from date(1).
FStream << llvm::format(
- "%.6lu", duration_cast<nanoseconds>(Fractional).count());
+ "%.6lu", (long)duration_cast<nanoseconds>(Fractional).count());
++I;
continue;
case '%': // Consume %%, so %%f parses as (%%)f not %(%f)
OpenPOWER on IntegriCloud