[PATCH] D81357: [DWARFYAML][debug_ranges] Emit an error message for invalid offset.

Xing GUO via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 8 07:05:24 PDT 2020


Higuoxing added inline comments.


================
Comment at: llvm/lib/ObjectYAML/DWARFEmitter.cpp:134
     const size_t CurrOffset = OS.tell() - RangesOffset;
-    assert(DebugRanges.Offset >= CurrOffset &&
-           "Offset should be greater than or equal to the bytes that we have "
-           "written");
+    if ((uint64_t)DebugRanges.Offset < CurrOffset)
+      return createStringError(errc::invalid_argument,
----------------
jhenderson wrote:
> Do you need the new cast? If I've followed it correctly, `Offset` is a `Hex64`, so is already a 64-bit number.
Yes, but the compiler complains that 'Use of overloaded operator '<' is ambiguous'. So we have to explicitly cast it to `uint64_t`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81357/new/

https://reviews.llvm.org/D81357





More information about the llvm-commits mailing list