summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/DebugLoc.cpp
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
commitda925c0d7c7a4e3857d29efda9579c16f67098ab (patch)
treeeb04fa79507bddd706c60ab4a1b2ec781a6ff7fa /llvm/lib/IR/DebugLoc.cpp
parent79dffb412840c1487396be5fa07e8cfb8ac0d07d (diff)
downloadbcm5719-llvm-da925c0d7c7a4e3857d29efda9579c16f67098ab.tar.gz
bcm5719-llvm-da925c0d7c7a4e3857d29efda9579c16f67098ab.zip
[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
Diffstat (limited to 'llvm/lib/IR/DebugLoc.cpp')
-rw-r--r--llvm/lib/IR/DebugLoc.cpp22
1 files changed, 22 insertions, 0 deletions
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 << "<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
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud