diff options
author | Chris Lattner <sabre@nondot.org> | 2010-04-01 03:55:42 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-04-01 03:55:42 +0000 |
commit | 56e4b4a913d8028fb7621f6ab1e2e4f3b05fb584 (patch) | |
tree | f3074ad5dff605d6168c9e002e1a57be03c00a3d /llvm/lib/VMCore/DebugLoc.cpp | |
parent | 8cea7f6f70290386808d43b5cc7a14c6946823d0 (diff) | |
download | bcm5719-llvm-56e4b4a913d8028fb7621f6ab1e2e4f3b05fb584.tar.gz bcm5719-llvm-56e4b4a913d8028fb7621f6ab1e2e4f3b05fb584.zip |
add a method to decode a DILocation into a NewDebugLoc.
llvm-svn: 100081
Diffstat (limited to 'llvm/lib/VMCore/DebugLoc.cpp')
-rw-r--r-- | llvm/lib/VMCore/DebugLoc.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/DebugLoc.cpp b/llvm/lib/VMCore/DebugLoc.cpp index 0fcbf2653aa..d9f533a9d60 100644 --- a/llvm/lib/VMCore/DebugLoc.cpp +++ b/llvm/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 |