[llvm-commits] [llvm] r159881 - /llvm/trunk/lib/VMCore/DebugLoc.cpp
Bill Wendling
isanbard at gmail.com
Fri Jul 6 17:52:35 PDT 2012
Author: void
Date: Fri Jul 6 19:52:35 2012
New Revision: 159881
URL: http://llvm.org/viewvc/llvm-project?rev=159881&view=rev
Log:
Use the DebugInfo wrappers instead of mucking about with the MDNode directly.
Modified:
llvm/trunk/lib/VMCore/DebugLoc.cpp
Modified: llvm/trunk/lib/VMCore/DebugLoc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/DebugLoc.cpp?rev=159881&r1=159880&r2=159881&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/DebugLoc.cpp (original)
+++ llvm/trunk/lib/VMCore/DebugLoc.cpp Fri Jul 6 19:52:35 2012
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/DebugLoc.h"
+#include "llvm/DebugInfo.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "LLVMContextImpl.h"
using namespace llvm;
@@ -114,34 +115,19 @@
/// getFromDILocation - Translate the DILocation quad into a DebugLoc.
DebugLoc DebugLoc::getFromDILocation(MDNode *N) {
- if (N == 0 || N->getNumOperands() != 4) return DebugLoc();
-
- MDNode *Scope = dyn_cast_or_null<MDNode>(N->getOperand(2));
+ DILocation Loc(N);
+ MDNode *Scope = Loc.getScope();
if (Scope == 0) return DebugLoc();
-
- 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)));
+ return get(Loc.getLineNumber(), Loc.getColumnNumber(), Scope,
+ Loc.getOrigLocation());
}
/// getFromDILexicalBlock - Translate the DILexicalBlock into a DebugLoc.
DebugLoc DebugLoc::getFromDILexicalBlock(MDNode *N) {
- if (N == 0 || N->getNumOperands() < 3) return DebugLoc();
-
- MDNode *Scope = dyn_cast_or_null<MDNode>(N->getOperand(1));
+ DILexicalBlock LexBlock(N);
+ MDNode *Scope = LexBlock.getContext();
if (Scope == 0) return DebugLoc();
-
- unsigned LineNo = 0, ColNo = 0;
- if (ConstantInt *Line = dyn_cast_or_null<ConstantInt>(N->getOperand(2)))
- LineNo = Line->getZExtValue();
- if (ConstantInt *Col = dyn_cast_or_null<ConstantInt>(N->getOperand(3)))
- ColNo = Col->getZExtValue();
-
- return get(LineNo, ColNo, Scope, NULL);
+ return get(LexBlock.getLineNumber(), LexBlock.getColumnNumber(), Scope, NULL);
}
void DebugLoc::dump(const LLVMContext &Ctx) const {
More information about the llvm-commits
mailing list