DebugInfo: Allow DebugLocs to be constructed from const

Allow `const`-qualified pointers to be used to construct `DebugLoc`s, as
a convenience.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235115 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith
2015-04-16 16:56:29 +00:00
parent 896b86d421
commit d6629b3db8
2 changed files with 11 additions and 9 deletions

View File

@ -16,8 +16,8 @@ using namespace llvm;
//===----------------------------------------------------------------------===//
// DebugLoc Implementation
//===----------------------------------------------------------------------===//
DebugLoc::DebugLoc(MDLocation *L) : Loc(L) {}
DebugLoc::DebugLoc(MDNode *L) : Loc(L) {}
DebugLoc::DebugLoc(const MDLocation *L) : Loc(const_cast<MDLocation *>(L)) {}
DebugLoc::DebugLoc(const MDNode *L) : Loc(const_cast<MDNode *>(L)) {}
MDLocation *DebugLoc::get() const {
return cast_or_null<MDLocation>(Loc.get());
@ -56,13 +56,15 @@ DebugLoc DebugLoc::getFnDebugLoc() const {
return DebugLoc();
}
DebugLoc DebugLoc::get(unsigned Line, unsigned Col,
MDNode *Scope, MDNode *InlinedAt) {
DebugLoc DebugLoc::get(unsigned Line, unsigned Col, const MDNode *Scope,
const MDNode *InlinedAt) {
// If no scope is available, this is an unknown location.
if (!Scope)
return DebugLoc();
return MDLocation::get(Scope->getContext(), Line, Col, Scope, InlinedAt);
return MDLocation::get(Scope->getContext(), Line, Col,
const_cast<MDNode *>(Scope),
const_cast<MDNode *>(InlinedAt));
}
void DebugLoc::dump() const {