]> granicus.if.org Git - llvm/commitdiff
[Remarks] Fix warning for uint8_t < 0 comparison
authorFrancis Visoiu Mistrih <francisvm@yahoo.com>
Mon, 9 Sep 2019 19:47:25 +0000 (19:47 +0000)
committerFrancis Visoiu Mistrih <francisvm@yahoo.com>
Mon, 9 Sep 2019 19:47:25 +0000 (19:47 +0000)
http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/19109/steps/build-stage1-compiler/logs/stdio

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

lib/Remarks/BitstreamRemarkParser.cpp

index a65e845bd5357fece6534d6577e2bc667033a6b9..2da236233450b9efbe3472063b525e10308b0e8b 100644 (file)
@@ -365,8 +365,8 @@ Error BitstreamRemarkParser::processCommonMeta(
         "Error while parsing BLOCK_META: missing container version.");
 
   if (Optional<uint8_t> Type = MetaHelper.ContainerType) {
-    if (*Type < static_cast<uint8_t>(BitstreamRemarkContainerType::First) ||
-        *Type > static_cast<uint8_t>(BitstreamRemarkContainerType::Last))
+    // Always >= BitstreamRemarkContainerType::First since it's unsigned.
+    if (*Type > static_cast<uint8_t>(BitstreamRemarkContainerType::Last))
       return createStringError(
           std::make_error_code(std::errc::illegal_byte_sequence),
           "Error while parsing BLOCK_META: invalid container type.");
@@ -493,8 +493,8 @@ BitstreamRemarkParser::processRemark(BitstreamRemarkParserHelper &Helper) {
         std::make_error_code(std::errc::illegal_byte_sequence),
         "Error while parsing BLOCK_REMARK: missing remark type.");
 
-  if (*Helper.Type < static_cast<uint8_t>(Type::First) ||
-      *Helper.Type > static_cast<uint8_t>(Type::Last))
+  // Always >= Type::First since it's unsigned.
+  if (*Helper.Type > static_cast<uint8_t>(Type::Last))
     return createStringError(
         std::make_error_code(std::errc::illegal_byte_sequence),
         "Error while parsing BLOCK_REMARK: unknown remark type.");