Fix getFieldAs() to use the parameter instead of 6.
authorTorok Edwin <edwintorok@gmail.com>
Sat, 13 Dec 2008 08:25:29 +0000 (08:25 +0000)
committerTorok Edwin <edwintorok@gmail.com>
Sat, 13 Dec 2008 08:25:29 +0000 (08:25 +0000)
Add missing DIType constructor, needed by DIVariable::getType().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60976 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/DebugInfo.h
lib/Analysis/DebugInfo.cpp

index 1ee4f5ba44871695193c21d077b5f5e9cfd791bc..c0a43b3b76165e7339e623240b6f289979e997b7 100644 (file)
@@ -60,7 +60,7 @@ namespace llvm {
     
     template <typename DescTy>
     DescTy getFieldAs(unsigned Elt) const {
-      return DescTy(getDescriptorField(6).getGV());
+      return DescTy(getDescriptorField(Elt).getGV());
     }
   
     GlobalVariable *getGlobalVariableField(unsigned Elt) const;
index 01db8abf4e256439fef85920ef680c4e920796e0..29175a6a2d4e8bbf7f22182d2fde04a47636f83d 100644 (file)
@@ -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.