aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore/DebugLoc.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2011-07-14 01:14:57 +0000
committerDevang Patel <dpatel@apple.com>2011-07-14 01:14:57 +0000
commitd77ec6208cef2a8e615181c2bf0fc5a50a37a20b (patch)
treed8331e8707d219689ef95c84108e5ef17199ac22 /lib/VMCore/DebugLoc.cpp
parent7332e6ee25378e19c0f621c80c32b283b07f428a (diff)
Simplify and delay extracting DebugLoc elements, scope and InlinedAt, as much as possible.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135124 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/DebugLoc.cpp')
-rw-r--r--lib/VMCore/DebugLoc.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/VMCore/DebugLoc.cpp b/lib/VMCore/DebugLoc.cpp
index 520333cbbc..92ab4396fa 100644
--- a/lib/VMCore/DebugLoc.cpp
+++ b/lib/VMCore/DebugLoc.cpp
@@ -128,6 +128,22 @@ DebugLoc DebugLoc::getFromDILocation(MDNode *N) {
return get(LineNo, ColNo, Scope, dyn_cast_or_null<MDNode>(N->getOperand(3)));
}
+/// 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));
+ 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);
+}
+
//===----------------------------------------------------------------------===//
// DenseMap specialization
//===----------------------------------------------------------------------===//