/// getOriginalTypeSize - If this type is derived from a base type then /// return base type size. uint64_t DIDerivedType::getOriginalTypeSize() const { unsigned Tag = getTag(); if (Tag == dwarf::DW_TAG_member || Tag == dwarf::DW_TAG_typedef || Tag == dwarf::DW_TAG_const_type || Tag == dwarf::DW_TAG_volatile_type || Tag == dwarf::DW_TAG_restrict_type) { DIType BaseType = getTypeDerivedFrom(); // If this type is not derived from any type then take conservative // approach. if (!BaseType.isValid()) return getSizeInBits(); // If this is a derived type, go ahead and get the base type, unless // it's a reference then it's just the size of the field. Pointer types // have no need of this since they're a different type of qualification // on the type. if (BaseType.getTag() == dwarf::DW_TAG_reference_type) return getSizeInBits(); else if (BaseType.isDerivedType()) return DIDerivedType(BaseType).getOriginalTypeSize(); else return BaseType.getSizeInBits(); } return getSizeInBits(); }
DIType DebugInfo::getDoubleTy() { if (DblTy.isValid()) return DblTy; DblTy = DBuilder->createBasicType("double", 64, 64, dwarf::DW_ATE_float); return DblTy; }
/// addType - Add type into Tys. bool DebugInfoFinder::addType(DIType DT) { if (!DT.isValid()) return false; if (!NodesSeen.insert(DT)) return false; TYs.push_back(DT); return true; }
/// getOriginalTypeSize - If this type is derived from a base type then /// return base type size. uint64_t DIDerivedType::getOriginalTypeSize() const { unsigned Tag = getTag(); if (Tag == dwarf::DW_TAG_member || Tag == dwarf::DW_TAG_typedef || Tag == dwarf::DW_TAG_const_type || Tag == dwarf::DW_TAG_volatile_type || Tag == dwarf::DW_TAG_restrict_type) { DIType BaseType = getTypeDerivedFrom(); // If this type is not derived from any type then take conservative // approach. if (!BaseType.isValid()) return getSizeInBits(); if (BaseType.isDerivedType()) return DIDerivedType(BaseType).getOriginalTypeSize(); else return BaseType.getSizeInBits(); } return getSizeInBits(); }
/// getOrCreateType - Get the type from the cache or create a new type if /// necessary. DIType DebugInfo::getOrCreateType(tree type) { DEBUGASSERT(type != NULL_TREE && type != error_mark_node && "Not a type."); if (type == NULL_TREE || type == error_mark_node) return DIType(); // Should only be void if a pointer/reference/return type. Returning NULL // allows the caller to produce a non-derived type. if (TREE_CODE(type) == VOID_TYPE) return DIType(); // Check to see if the compile unit already has created this type. std::map<tree_node *, WeakVH >::iterator I = TypeCache.find(type); if (I != TypeCache.end()) if (Value *M = I->second) return DIType(cast<MDNode>(M)); DIType MainTy; if (type != TYPE_MAIN_VARIANT(type) && TYPE_MAIN_VARIANT(type)) MainTy = getOrCreateType(TYPE_MAIN_VARIANT(type)); DIType Ty = createVariantType(type, MainTy); if (Ty.isValid()) return Ty; // Work out details of type. switch (TREE_CODE(type)) { case ERROR_MARK: case LANG_TYPE: case TRANSLATION_UNIT_DECL: default: { DEBUGASSERT(0 && "Unsupported type"); return DIType(); } case POINTER_TYPE: case REFERENCE_TYPE: // Do not cache pointer type. The pointer may point to forward declared // struct. return createPointerType(type); break; case BLOCK_POINTER_TYPE: { DEBUGASSERT (generic_block_literal_struct_type && "Generic struct type for Blocks is missing!"); tree tmp_type = build_pointer_type(generic_block_literal_struct_type); Ty = createPointerType(tmp_type); break; } case OFFSET_TYPE: { // gen_type_die(TYPE_OFFSET_BASETYPE(type), context_die); // gen_type_die(TREE_TYPE(type), context_die); // gen_ptr_to_mbr_type_die(type, context_die); // PR 7104 break; } case FUNCTION_TYPE: case METHOD_TYPE: Ty = createMethodType(type); break; case VECTOR_TYPE: case ARRAY_TYPE: Ty = createArrayType(type); break; case ENUMERAL_TYPE: Ty = createEnumType(type); break; case RECORD_TYPE: case QUAL_UNION_TYPE: case UNION_TYPE: return createStructType(type); break; case INTEGER_TYPE: case REAL_TYPE: case COMPLEX_TYPE: case BOOLEAN_TYPE: Ty = createBasicType(type); break; } TypeCache[type] = WeakVH(Ty.getNode()); return Ty; }