[Lldb-commits] [lldb] [libc] [llvm] [clang] [mlir] [NFC][ObjectSizeOffset] Use classes instead of std::pair (PR #76882)
Nikita Popov via lldb-commits
lldb-commits at lists.llvm.org
Thu Jan 4 07:15:00 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;
----------------
nikic wrote:
Use CRTP instead of virtual dispatch?
Should at least make the child classes final if you're using virtual.
https://github.com/llvm/llvm-project/pull/76882
More information about the lldb-commits
mailing list