From: Duncan P. N. Exon Smith Date: Mon, 30 Mar 2015 17:41:24 +0000 (+0000) Subject: DebugInfo: Implement MDLocation::getInlinedAtScope() X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=3584797a17873c2692425db0bec64a9252879fc3;p=oota-llvm.git DebugInfo: Implement MDLocation::getInlinedAtScope() Write `MDLocation::getInlinedAtScope()` and use it to re-implement `DebugLoc::getScopeNode()` (and simplify `DISubprogram::Verify()`). This follows the inlined-at linked list and returns the scope of the deepest/last location. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233568 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/IR/DebugInfoMetadata.h b/include/llvm/IR/DebugInfoMetadata.h index 5097ecf4c8b..a1e229e3743 100644 --- a/include/llvm/IR/DebugInfoMetadata.h +++ b/include/llvm/IR/DebugInfoMetadata.h @@ -949,6 +949,16 @@ public: return cast_or_null(getRawInlinedAt()); } + /// \brief Get the scope where this is inlined. + /// + /// Walk through \a getInlinedAt() and return \a getScope() from the deepest + /// location. + MDLocalScope *getInlinedAtScope() const { + if (auto *IA = getInlinedAt()) + return IA->getInlinedAtScope(); + return getScope(); + } + Metadata *getRawScope() const { return getOperand(0); } Metadata *getRawInlinedAt() const { if (getNumOperands() == 2) diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index ec4f95eb71f..e16ac8c20f6 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -349,9 +349,7 @@ bool DISubprogram::Verify() const { continue; // walk the inlined-at scopes - while (MDLocation *IA = DL->getInlinedAt()) - DL = IA; - MDScope *Scope = DL->getScope(); + MDScope *Scope = DL->getInlinedAtScope(); if (!Scope) return false; while (!isa(Scope)) { diff --git a/lib/IR/DebugLoc.cpp b/lib/IR/DebugLoc.cpp index e1bf7951a58..6b2a5395930 100644 --- a/lib/IR/DebugLoc.cpp +++ b/lib/IR/DebugLoc.cpp @@ -33,9 +33,7 @@ void DebugLoc::getScopeAndInlinedAt(MDNode *&Scope, MDNode *&IA) const { } MDNode *DebugLoc::getScopeNode() const { - if (MDNode *InlinedAt = getInlinedAt()) - return DebugLoc::getFromDILocation(InlinedAt).getScopeNode(); - return getScope(); + return cast(Loc)->getInlinedAtScope(); } DebugLoc DebugLoc::getFnDebugLoc() const {