From 8898288749e8b5d9c27a04cc454ad64910ac3c66 Mon Sep 17 00:00:00 2001 From: Torok Edwin Date: Sat, 13 Dec 2008 08:25:29 +0000 Subject: [PATCH] Fix getFieldAs() to use the parameter instead of 6. Add missing DIType constructor, needed by DIVariable::getType(). llvm-svn: 60976 --- include/llvm/Analysis/DebugInfo.h | 2 +- lib/Analysis/DebugInfo.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/llvm/Analysis/DebugInfo.h b/include/llvm/Analysis/DebugInfo.h index 1ee4f5ba448..c0a43b3b761 100644 --- a/include/llvm/Analysis/DebugInfo.h +++ b/include/llvm/Analysis/DebugInfo.h @@ -60,7 +60,7 @@ namespace llvm { template DescTy getFieldAs(unsigned Elt) const { - return DescTy(getDescriptorField(6).getGV()); + return DescTy(getDescriptorField(Elt).getGV()); } GlobalVariable *getGlobalVariableField(unsigned Elt) const; diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp index 01db8abf4e2..29175a6a2d4 100644 --- a/lib/Analysis/DebugInfo.cpp +++ b/lib/Analysis/DebugInfo.cpp @@ -100,6 +100,14 @@ DIGlobalVariable::DIGlobalVariable(GlobalVariable *GV) : DIGlobal(GV, dwarf::DW_TAG_variable) {} DIBlock::DIBlock(GlobalVariable *GV) : DIDescriptor(GV, dwarf::DW_TAG_lexical_block) {} +// needed by DIVariable::getType() +DIType::DIType(GlobalVariable *GV) : DIDescriptor(GV) { + if (!GV) return; + unsigned tag = getTag(); + if (tag != dwarf::DW_TAG_base_type && !DIDerivedType::isDerivedType(tag) && + !DICompositeType::isCompositeType(tag)) + GV = 0; +} /// isDerivedType - Return true if the specified tag is legal for /// DIDerivedType.