Skip to content

Commit 394b18e

Browse files
[DebugInfo] Helper method for finding the deepest inlining location
1 parent 407ecfe commit 394b18e

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

llvm/include/llvm/IR/DebugInfoMetadata.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2600,14 +2600,23 @@ class DILocation : public MDNode {
26002600
StringRef getDirectory() const { return getScope()->getDirectory(); }
26012601
std::optional<StringRef> getSource() const { return getScope()->getSource(); }
26022602

2603+
/// Get the location where this is inlined
2604+
///
2605+
/// Walk through \a getInlinedAt() and return the \a DILocation where this is
2606+
/// inlined.
2607+
const DILocation *getInlinedAtLocation() const {
2608+
const DILocation *Current = this, *Next = nullptr;
2609+
while (Next = Current->getInlinedAt())
2610+
Current = Next;
2611+
return Current;
2612+
}
2613+
26032614
/// Get the scope where this is inlined.
26042615
///
26052616
/// Walk through \a getInlinedAt() and return \a getScope() from the deepest
26062617
/// location.
26072618
DILocalScope *getInlinedAtScope() const {
2608-
if (auto *IA = getInlinedAt())
2609-
return IA->getInlinedAtScope();
2610-
return getScope();
2619+
return getInlinedAtLocation()->getScope();
26112620
}
26122621

26132622
/// Get the DWARF discriminator.

0 commit comments

Comments
 (0)