================
@@ -2527,6 +2527,83 @@ bool arePotentiallyOverlappingStringLiterals(const
Pointer &LHS,
return Shorter == Longer.take_front(Shorter.size());
}
+static const MaterializeTemporaryExpr *
+getInitializerListBackingArray(const Pointer &Ptr) {
+ if (Ptr.isZero() || !Ptr.isBlockPointer() || Ptr.block()->isDynamic())
+ return nullptr;
+
+ const auto *MTE =
+ dyn_cast_or_null<MaterializeTemporaryExpr>(Ptr.getDeclDesc()->asExpr());
+ return IsInitializerListBackingArray(MTE) ? MTE : nullptr;
+}
+
+static bool getArrayIndex(const Pointer &Ptr, Pointer &Array, uint64_t &Index)
{
----------------
yronglin wrote:
Renamed to `getArraySubobjectLocation` and added more comments in code. It
locates a pointer relative to its enclosing initializer-list backing array —
returning the array, the element index (or the array length when
one-past-the-end), and the offset within that element — or `std::nullopt` when
the pointer does not designate such a position. It mirrors the AST-side
overload with the same name in `ExprConstant.cpp`, and the bounds/offset
arithmetic is now shared via `getArraySubobjectLocationImpl` in
`ExprConstShared.h`.
https://github.com/llvm/llvm-project/pull/197458
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits