[llvm] [Object] Parsing and dumping of SFrame FDEs (PR #149828)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 23 01:13:08 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 ||
----------------
jh7370 wrote:

Should overflow have its own error message? I could imagine the values in the current warning might be a bit confusing if there was an overflow...

https://github.com/llvm/llvm-project/pull/149828


More information about the llvm-commits mailing list