From da925c0d7c7a4e3857d29efda9579c16f67098ab Mon Sep 17 00:00:00 2001 From: Zinovy Nis Date: Wed, 7 May 2014 09:51:22 +0000 Subject: [BUG][REFACTOR] 1) Fix for printing debug locations for absolute paths. 2) Location printing is moved into public method DebugLoc::print() to avoid re-inventing the wheel. Differential Revision: http://reviews.llvm.org/D3513 llvm-svn: 208177 --- llvm/lib/IR/DebugLoc.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'llvm/lib/IR/DebugLoc.cpp') diff --git a/llvm/lib/IR/DebugLoc.cpp b/llvm/lib/IR/DebugLoc.cpp index 77faa7cc66b..43360d38662 100644 --- a/llvm/lib/IR/DebugLoc.cpp +++ b/llvm/lib/IR/DebugLoc.cpp @@ -167,6 +167,28 @@ void DebugLoc::dump(const LLVMContext &Ctx) const { #endif } +void DebugLoc::print(const LLVMContext &Ctx, raw_ostream &OS) const { + if (!isUnknown()) { + // Print source line info. + DIScope Scope(getScope(Ctx)); + assert((!Scope || Scope.isScope()) && + "Scope of a DebugLoc should be null or a DIScope."); + if (Scope) + OS << Scope.getFilename(); + else + OS << ""; + OS << ':' << getLine(); + if (getCol() != 0) + OS << ':' << getCol(); + DebugLoc InlinedAtDL = DebugLoc::getFromDILocation(getInlinedAt(Ctx)); + if (!InlinedAtDL.isUnknown()) { + OS << " @[ "; + InlinedAtDL.print(Ctx, OS); + OS << " ]"; + } + } +} + //===----------------------------------------------------------------------===// // DenseMap specialization //===----------------------------------------------------------------------===// -- cgit v1.2.3