[llvm] [Object] Parsing and dumping of SFrame FDEs (PR #149828)
Pavel Labath via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 24 07:41:57 PDT 2025
================
@@ -14,23 +14,35 @@
using namespace llvm;
using namespace llvm::object;
-template <typename T>
-static Expected<const T &> getDataSliceAs(ArrayRef<uint8_t> Data,
- uint64_t Offset) {
- static_assert(std::is_trivial_v<T>);
- if (Data.size() < Offset + sizeof(T)) {
+static Expected<ArrayRef<uint8_t>>
+getDataSlice(ArrayRef<uint8_t> Data, uint64_t Offset, uint64_t Size) {
+ // Check for overflow.
+ if (Offset + Size < Offset || Offset + Size < Size ||
----------------
labath wrote:
Or maybe use saturating arithmetic, which gets rid of the strange checks and produces mostly-reasonable errors.
https://github.com/llvm/llvm-project/pull/149828
More information about the llvm-commits
mailing list