The only user of `DebugLoc::getFromDILexicalBlock()` was creating a new
`MDLocation` as convenient API for passing an `MDScope`. Stop doing
that, and remove the API. If in the future we actually *want* to create
new DebugLocs, calling `MDLexicalBlock::get()` makes more sense.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233643
91177308-0d34-0410-b5e6-
96231b3b80d8
LexicalScope *getOrCreateAbstractScope(const MDLocalScope *Scope);
private:
LexicalScope *getOrCreateAbstractScope(const MDLocalScope *Scope);
private:
- /// getOrCreateLexicalScope - Find lexical scope for the given DebugLoc. If
+ /// getOrCreateLexicalScope - Find lexical scope for the given Scope/IA. If
/// not available then create new lexical scope.
/// not available then create new lexical scope.
- LexicalScope *getOrCreateLexicalScope(const MDLocation *DL);
+ LexicalScope *getOrCreateLexicalScope(const MDLocalScope *Scope,
+ const MDLocation *IA = nullptr);
+ LexicalScope *getOrCreateLexicalScope(const MDLocation *DL) {
+ return DL ? getOrCreateLexicalScope(DL->getScope(), DL->getInlinedAt())
+ : nullptr;
+ }
/// getOrCreateRegularScope - Find or create a regular lexical scope.
LexicalScope *getOrCreateRegularScope(const MDLocalScope *Scope);
/// getOrCreateRegularScope - Find or create a regular lexical scope.
LexicalScope *getOrCreateRegularScope(const MDLocalScope *Scope);
static DebugLoc get(unsigned Line, unsigned Col, MDNode *Scope,
MDNode *InlinedAt = nullptr);
static DebugLoc get(unsigned Line, unsigned Col, MDNode *Scope,
MDNode *InlinedAt = nullptr);
- /// \brief Translate the DILexicalBlock into a DebugLoc.
- ///
- /// FIXME: Remove this. It has only one user, and the user just wants to
- /// pass an \a MDScope around.
- static DebugLoc getFromDILexicalBlock(MDNode *N);
-
unsigned getLine() const;
unsigned getCol() const;
MDNode *getScope() const;
unsigned getLine() const;
unsigned getCol() const;
MDNode *getScope() const;
/// getOrCreateLexicalScope - Find lexical scope for the given DebugLoc. If
/// not available then create new lexical scope.
/// getOrCreateLexicalScope - Find lexical scope for the given DebugLoc. If
/// not available then create new lexical scope.
-LexicalScope *LexicalScopes::getOrCreateLexicalScope(const MDLocation *DL) {
- if (!DL)
- return nullptr;
- MDLocalScope *Scope = DL->getScope();
- if (auto *InlinedAt = DL->getInlinedAt()) {
+LexicalScope *LexicalScopes::getOrCreateLexicalScope(const MDLocalScope *Scope,
+ const MDLocation *IA) {
+ if (IA) {
// Create an abstract scope for inlined function.
getOrCreateAbstractScope(Scope);
// Create an inlined scope for inlined function.
// Create an abstract scope for inlined function.
getOrCreateAbstractScope(Scope);
// Create an inlined scope for inlined function.
- return getOrCreateInlinedScope(Scope, InlinedAt);
+ return getOrCreateInlinedScope(Scope, IA);
}
return getOrCreateRegularScope(Scope);
}
return getOrCreateRegularScope(Scope);
if (I != LexicalScopeMap.end())
return &I->second;
if (I != LexicalScopeMap.end())
return &I->second;
+ // FIXME: Should the following dyn_cast be MDLexicalBlock?
LexicalScope *Parent = nullptr;
LexicalScope *Parent = nullptr;
- if (isa<MDLexicalBlockBase>(Scope)) // FIXME: Should this be MDLexicalBlock?
- Parent =
- getOrCreateLexicalScope(DebugLoc::getFromDILexicalBlock(
- const_cast<MDLocalScope *>(Scope)).get());
+ if (auto *Block = dyn_cast<MDLexicalBlockBase>(Scope))
+ Parent = getOrCreateLexicalScope(Block->getScope());
I = LexicalScopeMap.emplace(std::piecewise_construct,
std::forward_as_tuple(Scope),
std::forward_as_tuple(Parent, Scope, nullptr,
I = LexicalScopeMap.emplace(std::piecewise_construct,
std::forward_as_tuple(Scope),
std::forward_as_tuple(Parent, Scope, nullptr,
return MDLocation::get(Scope->getContext(), Line, Col, Scope, InlinedAt);
}
return MDLocation::get(Scope->getContext(), Line, Col, Scope, InlinedAt);
}
-/// getFromDILexicalBlock - Translate the DILexicalBlock into a DebugLoc.
-DebugLoc DebugLoc::getFromDILexicalBlock(MDNode *N) {
- DILexicalBlock LexBlock(N);
- MDNode *Scope = LexBlock.getContext();
- if (!Scope) return DebugLoc();
- return get(LexBlock.getLineNumber(), LexBlock.getColumnNumber(), Scope,
- nullptr);
-}
-
void DebugLoc::dump() const {
#ifndef NDEBUG
if (!Loc)
void DebugLoc::dump() const {
#ifndef NDEBUG
if (!Loc)