From 3dcb4ef757127d69c3748dec92787520e039bd53 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Thu, 14 Jul 2011 21:50:04 +0000 Subject: [PATCH] Add dump() git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135200 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/DebugLoc.h | 2 ++ lib/VMCore/DebugLoc.cpp | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/llvm/Support/DebugLoc.h b/include/llvm/Support/DebugLoc.h index c90915f41a1..2ee9f876c36 100644 --- a/include/llvm/Support/DebugLoc.h +++ b/include/llvm/Support/DebugLoc.h @@ -97,6 +97,8 @@ namespace llvm { return LineCol == DL.LineCol && ScopeIdx == DL.ScopeIdx; } bool operator!=(const DebugLoc &DL) const { return !(*this == DL); } + + void dump(const LLVMContext &Ctx) const; }; template <> diff --git a/lib/VMCore/DebugLoc.cpp b/lib/VMCore/DebugLoc.cpp index 92ab4396fa1..4ff6b2cd80e 100644 --- a/lib/VMCore/DebugLoc.cpp +++ b/lib/VMCore/DebugLoc.cpp @@ -144,6 +144,22 @@ DebugLoc DebugLoc::getFromDILexicalBlock(MDNode *N) { return get(LineNo, ColNo, Scope, NULL); } +void DebugLoc::dump(const LLVMContext &Ctx) const { +#ifndef NDEBUG + if (!isUnknown()) { + dbgs() << getLine(); + if (getCol() != 0) + dbgs() << ',' << getCol(); + DebugLoc InlinedAtDL = DebugLoc::getFromDILocation(getInlinedAt(Ctx)); + if (!InlinedAtDL.isUnknown()) { + dbgs() << " @ "; + InlinedAtDL.dump(Ctx); + } else + dbgs() << "\n"; + } +#endif +} + //===----------------------------------------------------------------------===// // DenseMap specialization //===----------------------------------------------------------------------===//