summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-04-01 03:55:42 +0000
committerChris Lattner <sabre@nondot.org>2010-04-01 03:55:42 +0000
commit68c551349947e659a79eb0d4782d0487756020b5 (patch)
tree2670a5fd5071294345ca27012be83326cbc061b4 /lib
parentec306a9771dd151531e0af7a26ce973cfd43453d (diff)
downloadllvm-68c551349947e659a79eb0d4782d0487756020b5.tar.gz
llvm-68c551349947e659a79eb0d4782d0487756020b5.tar.bz2
llvm-68c551349947e659a79eb0d4782d0487756020b5.tar.xz
add a method to decode a DILocation into a NewDebugLoc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100081 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/VMCore/DebugLoc.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/VMCore/DebugLoc.cpp b/lib/VMCore/DebugLoc.cpp
index 0fcbf2653a..d9f533a9d6 100644
--- a/lib/VMCore/DebugLoc.cpp
+++ b/lib/VMCore/DebugLoc.cpp
@@ -111,6 +111,21 @@ MDNode *NewDebugLoc::getAsMDNode(const LLVMContext &Ctx) const {
return MDNode::get(Ctx2, &Elts[0], 4);
}
+/// getFromDILocation - Translate the DILocation quad into a NewDebugLoc.
+NewDebugLoc NewDebugLoc::getFromDILocation(MDNode *N) {
+ if (N == 0 || N->getNumOperands() != 4) return NewDebugLoc();
+
+ MDNode *Scope = dyn_cast_or_null<MDNode>(N->getOperand(2));
+ if (Scope == 0) return NewDebugLoc();
+
+ unsigned LineNo = 0, ColNo = 0;
+ if (ConstantInt *Line = dyn_cast_or_null<ConstantInt>(N->getOperand(0)))
+ LineNo = Line->getZExtValue();
+ if (ConstantInt *Col = dyn_cast_or_null<ConstantInt>(N->getOperand(1)))
+ ColNo = Col->getZExtValue();
+
+ return get(LineNo, ColNo, Scope, dyn_cast_or_null<MDNode>(N->getOperand(3)));
+}
//===----------------------------------------------------------------------===//
// LLVMContextImpl Implementation