[libc-commits] [lldb] [llvm] [mlir] [libc] [clang] [NFC][ObjectSizeOffset] Use classes instead of std::pair (PR #76882)
Bill Wendling via libc-commits
libc-commits at lists.llvm.org
Thu Jan 4 11:45:54 PST 2024
================
@@ -187,80 +187,124 @@ Value *lowerObjectSizeCall(
const TargetLibraryInfo *TLI, AAResults *AA, bool MustSucceed,
SmallVectorImpl<Instruction *> *InsertedInstructions = nullptr);
-using SizeOffsetType = std::pair<APInt, APInt>;
+/// SizeOffsetType - A base template class for the object size visitors. Used
+/// here as a self-documenting way to handle the values rather than using a
+/// \p std::pair.
+template <typename T> struct SizeOffsetType {
+ T Size;
+ T Offset;
+
+ SizeOffsetType() = default;
+ SizeOffsetType(T Size, T Offset) : Size(Size), Offset(Offset) {}
+ virtual ~SizeOffsetType() = default;
+
+ virtual bool knownSize() const = 0;
+ virtual bool knownOffset() const = 0;
----------------
bwendling wrote:
Good idea! :-) CRTP done.
https://github.com/llvm/llvm-project/pull/76882
More information about the libc-commits
mailing list