From 7b246c38724a9c79336fff87af668136fb676fe6 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 3 Dec 2012 19:44:25 +0000 Subject: [PATCH] Add 'getInt64Field()' method to get the signed integer instead of unsigned. llvm-svn: 169145 --- llvm/include/llvm/DebugInfo.h | 1 + llvm/lib/VMCore/DebugInfo.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/llvm/include/llvm/DebugInfo.h b/llvm/include/llvm/DebugInfo.h index e66ee93..ee0505b 100644 --- a/llvm/include/llvm/DebugInfo.h +++ b/llvm/include/llvm/DebugInfo.h @@ -71,6 +71,7 @@ namespace llvm { return (unsigned)getUInt64Field(Elt); } uint64_t getUInt64Field(unsigned Elt) const; + int64_t getInt64Field(unsigned Elt) const; DIDescriptor getDescriptorField(unsigned Elt) const; template diff --git a/llvm/lib/VMCore/DebugInfo.cpp b/llvm/lib/VMCore/DebugInfo.cpp index 7d8cf72..73eb92e 100644 --- a/llvm/lib/VMCore/DebugInfo.cpp +++ b/llvm/lib/VMCore/DebugInfo.cpp @@ -75,6 +75,18 @@ uint64_t DIDescriptor::getUInt64Field(unsigned Elt) const { return 0; } +int64_t DIDescriptor::getInt64Field(unsigned Elt) const { + if (DbgNode == 0) + return 0; + + if (Elt < DbgNode->getNumOperands()) + if (ConstantInt *CI + = dyn_cast_or_null(DbgNode->getOperand(Elt))) + return CI->getSExtValue(); + + return 0; +} + DIDescriptor DIDescriptor::getDescriptorField(unsigned Elt) const { if (DbgNode == 0) return DIDescriptor(); -- 2.7.4