[llvm-commits] [llvm] r100081 - in /llvm/trunk: include/llvm/Support/DebugLoc.h lib/VMCore/DebugLoc.cpp
Chris Lattner
sabre at nondot.org
Wed Mar 31 20:55:42 PDT 2010
Author: lattner
Date: Wed Mar 31 22:55:42 2010
New Revision: 100081
URL: http://llvm.org/viewvc/llvm-project?rev=100081&view=rev
Log:
add a method to decode a DILocation into a NewDebugLoc.
Modified:
llvm/trunk/include/llvm/Support/DebugLoc.h
llvm/trunk/lib/VMCore/DebugLoc.cpp
Modified: llvm/trunk/include/llvm/Support/DebugLoc.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/DebugLoc.h?rev=100081&r1=100080&r2=100081&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/DebugLoc.h (original)
+++ llvm/trunk/include/llvm/Support/DebugLoc.h Wed Mar 31 22:55:42 2010
@@ -40,6 +40,9 @@
static NewDebugLoc get(unsigned Line, unsigned Col,
MDNode *Scope, MDNode *InlinedAt);
+ /// getFromDILocation - Translate the DILocation quad into a NewDebugLoc.
+ static NewDebugLoc getFromDILocation(MDNode *N);
+
/// isUnknown - Return true if this is an unknown location.
bool isUnknown() const { return ScopeIdx == 0; }
@@ -96,7 +99,7 @@
bool operator!=(const DebugLoc &DL) const { return !(*this == DL); }
};
- /// DebugLocTracker - This class tracks debug location information.
+ /// DebugLocTracker - This class tracks debug location information.
///
struct DebugLocTracker {
/// DebugLocations - A vector of unique DebugLocTuple's.
Modified: llvm/trunk/lib/VMCore/DebugLoc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/DebugLoc.cpp?rev=100081&r1=100080&r2=100081&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/DebugLoc.cpp (original)
+++ llvm/trunk/lib/VMCore/DebugLoc.cpp Wed Mar 31 22:55:42 2010
@@ -111,6 +111,21 @@
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
More information about the llvm-commits
mailing list