use different name for parameter to make it clear that we set DIDescriptor::GV
[oota-llvm.git] / lib / Analysis / DebugInfo.cpp
index 01db8abf4e256439fef85920ef680c4e920796e0..c46091c9554d3685d7ae5d4d447bd63e95222c5d 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.