Skip to content

Commit a17b71d

Browse files
committed
[NFC] Add DebugVariableAggregate class
A DebugVariableAggregate is a DebugVariable that discards FragmentInfo; it represents a whole variable instance. Reviewed By: StephenTozer Differential Revision: https://reviews.llvm.org/D146298
1 parent d4eb996 commit a17b71d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

llvm/include/llvm/IR/DebugInfoMetadata.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3817,6 +3817,18 @@ template <> struct DenseMapInfo<DebugVariable> {
38173817
}
38183818
};
38193819

3820+
/// Identifies a unique instance of a whole variable (discards/ignores fragment
3821+
/// information).
3822+
class DebugVariableAggregate : public DebugVariable {
3823+
public:
3824+
DebugVariableAggregate(const DbgVariableIntrinsic *DVI);
3825+
DebugVariableAggregate(const DebugVariable &V)
3826+
: DebugVariable(V.getVariable(), std::nullopt, V.getInlinedAt()) {}
3827+
};
3828+
3829+
template <>
3830+
struct DenseMapInfo<DebugVariableAggregate>
3831+
: public DenseMapInfo<DebugVariable> {};
38203832
} // end namespace llvm
38213833

38223834
#undef DEFINE_MDNODE_GET_UNPACK_IMPL

llvm/lib/IR/DebugInfoMetadata.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ DebugVariable::DebugVariable(const DbgVariableIntrinsic *DII)
4242
Fragment(DII->getExpression()->getFragmentInfo()),
4343
InlinedAt(DII->getDebugLoc().getInlinedAt()) {}
4444

45+
DebugVariableAggregate::DebugVariableAggregate(const DbgVariableIntrinsic *DVI)
46+
: DebugVariable(DVI->getVariable(), std::nullopt,
47+
DVI->getDebugLoc()->getInlinedAt()) {}
48+
4549
DILocation::DILocation(LLVMContext &C, StorageType Storage, unsigned Line,
4650
unsigned Column, ArrayRef<Metadata *> MDs,
4751
bool ImplicitCode)

0 commit comments

Comments
 (0)