[MC] Replace comparison with isUInt<32>.
authorDavid Majnemer <david.majnemer@gmail.com>
Fri, 4 Sep 2015 07:22:36 +0000 (07:22 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Fri, 4 Sep 2015 07:22:36 +0000 (07:22 +0000)
Casting to unsigned long can cause the time to get truncated to 32-bits,
making it appear to be a valid timestamp.  Just use isUInt<32> instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246840 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/WinCOFFObjectWriter.cpp

index 81facc01eed4160fe731693d43b979dbd20c56ab..9058edf33254a77bee3fe08c55f07e2ed8912796 100644 (file)
@@ -1016,7 +1016,7 @@ void WinCOFFObjectWriter::writeObject(MCAssembler &Asm,
   // MS LINK expects to be able to use this timestamp to implement their
   // /INCREMENTAL feature.
   std::time_t Now = time(nullptr);
-  if (Now < 0 || (unsigned long)Now > UINT32_MAX)
+  if (Now < 0 || !isUInt<32>(Now))
     Now = UINT32_MAX;
   Header.TimeDateStamp = Now;