From 721c201bd55ffb73cb2ba8d39e0570fa38c44e15 Mon Sep 17 00:00:00 2001 From: dim Date: Wed, 15 Aug 2012 19:34:23 +0000 Subject: Vendor import of llvm trunk r161861: http://llvm.org/svn/llvm-project/llvm/trunk@161861 --- lib/VMCore/DebugLoc.cpp | 42 ++++++++---------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) (limited to 'lib/VMCore/DebugLoc.cpp') diff --git a/lib/VMCore/DebugLoc.cpp b/lib/VMCore/DebugLoc.cpp index 9013d28..c6a3053 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(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(N->getOperand(0))) - LineNo = Line->getZExtValue(); - if (ConstantInt *Col = dyn_cast_or_null(N->getOperand(1))) - ColNo = Col->getZExtValue(); - - return get(LineNo, ColNo, Scope, dyn_cast_or_null(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(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(N->getOperand(2))) - LineNo = Line->getZExtValue(); - if (ConstantInt *Col = dyn_cast_or_null(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 { @@ -164,22 +150,10 @@ void DebugLoc::dump(const LLVMContext &Ctx) const { // DenseMap specialization //===----------------------------------------------------------------------===// -DebugLoc DenseMapInfo::getEmptyKey() { - return DebugLoc::getEmptyKey(); -} - -DebugLoc DenseMapInfo::getTombstoneKey() { - return DebugLoc::getTombstoneKey(); -} - unsigned DenseMapInfo::getHashValue(const DebugLoc &Key) { return static_cast(hash_combine(Key.LineCol, Key.ScopeIdx)); } -bool DenseMapInfo::isEqual(const DebugLoc &LHS, const DebugLoc &RHS) { - return LHS == RHS; -} - //===----------------------------------------------------------------------===// // LLVMContextImpl Implementation //===----------------------------------------------------------------------===// -- cgit v1.1