OSDN Git Service

Add dump()
authorDevang Patel <dpatel@apple.com>
Thu, 14 Jul 2011 21:50:04 +0000 (21:50 +0000)
committerDevang Patel <dpatel@apple.com>
Thu, 14 Jul 2011 21:50:04 +0000 (21:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135200 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/DebugLoc.h
lib/VMCore/DebugLoc.cpp

index c90915f..2ee9f87 100644 (file)
@@ -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 <>
index 92ab439..4ff6b2c 100644 (file)
@@ -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
 //===----------------------------------------------------------------------===//