diff options
author | Bill Wendling <isanbard@gmail.com> | 2012-07-07 00:52:35 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2012-07-07 00:52:35 +0000 |
commit | 9cb22d6c8c71dc79f0903ca4c105c3e727e2ce24 (patch) | |
tree | b14ba7dd4020a0a31cb10b59b2b1726d0ee4e834 /lib/VMCore | |
parent | ee17cee77cb9a887cf4055369a346dd59efdbff6 (diff) | |
download | external_llvm-9cb22d6c8c71dc79f0903ca4c105c3e727e2ce24.zip external_llvm-9cb22d6c8c71dc79f0903ca4c105c3e727e2ce24.tar.gz external_llvm-9cb22d6c8c71dc79f0903ca4c105c3e727e2ce24.tar.bz2 |
Use the DebugInfo wrappers instead of mucking about with the MDNode directly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159881 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/DebugLoc.cpp | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/lib/VMCore/DebugLoc.cpp b/lib/VMCore/DebugLoc.cpp index 9013d28..b8d8551 100644 --- a/lib/VMCore/DebugLoc.cpp +++ b/lib/VMCore/DebugLoc.cpp @@ -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 @@ MDNode *DebugLoc::getAsMDNode(const LLVMContext &Ctx) const { /// 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 { |