summaryrefslogtreecommitdiff
path: root/lib/IR
diff options
context:
space:
mode:
authorZinovy Nis <zinovy.nis@gmail.com>2014-05-07 09:51:22 +0000
committerZinovy Nis <zinovy.nis@gmail.com>2014-05-07 09:51:22 +0000
commit6a48f1c27136a77159892de4ae4a28d69ab970af (patch)
tree8891c6768209d6abde3ed008de14092e9698a937 /lib/IR
parentcb3a147870ff5f9374792aeedf09a5ff73e632ec (diff)
downloadllvm-6a48f1c27136a77159892de4ae4a28d69ab970af.tar.gz
llvm-6a48f1c27136a77159892de4ae4a28d69ab970af.tar.bz2
llvm-6a48f1c27136a77159892de4ae4a28d69ab970af.tar.xz
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208177 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR')
-rw-r--r--lib/IR/DebugLoc.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/IR/DebugLoc.cpp b/lib/IR/DebugLoc.cpp
index 77faa7cc66..43360d3866 100644
--- a/lib/IR/DebugLoc.cpp
+++ b/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 << "<unknown>";
+ OS << ':' << getLine();
+ if (getCol() != 0)
+ OS << ':' << getCol();
+ DebugLoc InlinedAtDL = DebugLoc::getFromDILocation(getInlinedAt(Ctx));
+ if (!InlinedAtDL.isUnknown()) {
+ OS << " @[ ";
+ InlinedAtDL.print(Ctx, OS);
+ OS << " ]";
+ }
+ }
+}
+
//===----------------------------------------------------------------------===//
// DenseMap specialization
//===----------------------------------------------------------------------===//