58 if (Type.getTag() == dwarf::DW_TAG_array_type) {
59 DIType *SubType = Type.getBaseType();
61 size_t Align = Type.getAlignInBytes();
62 size_t SubSize = SubType->getSizeInBits() / 8;
63 size_t Size = Type.getSizeInBits() / 8;
64 DINodeArray Subranges = Type.getElements();
66 for (
auto r : Subranges) {
67 DISubrange *Subrange = dyn_cast<DISubrange>(r);
68 if (
auto Count = Subrange->getCount().get<ConstantInt *>()) {
69 int64_t count =
Count->getSExtValue();
73 for (int64_t i = 0; i < count; i++) {
75 size_t tmp = pos + SubSize;
76 if (tmp % Align != 0) {
77 pos = (tmp / Align + 1) * Align;
83 assert(0 &&
"There shouldn't be non-constant-size arrays in Rust");
86 }
else if (Type.getTag() == dwarf::DW_TAG_structure_type ||
87 Type.getTag() == dwarf::DW_TAG_union_type) {
88 DINodeArray Elements = Type.getElements();
89 size_t Size = Type.getSizeInBits() / 8;
90 bool firstSubTT =
true;
91 for (
auto e : Elements) {
92 DIType *SubType = dyn_cast<DIDerivedType>(e);
93 assert(SubType->getTag() == dwarf::DW_TAG_member);
95 size_t Offset = SubType->getOffsetInBits() / 8;
97 if (Type.getTag() == dwarf::DW_TAG_structure_type) {
107 firstSubTT = !firstSubTT;
111 assert(0 &&
"Composite types other than arrays, structs and unions are not "
112 "supported by Rust debug info parser");
118 if (Type.getTag() == dwarf::DW_TAG_pointer_type) {
120 DIType *SubType = Type.getBaseType();
122 if (isa<DIBasicType>(SubType)) {
127 return Result.
Only(0, &I);
128 }
else if (Type.getTag() == dwarf::DW_TAG_member) {
129 DIType *SubType = Type.getBaseType();
133 assert(0 &&
"Derived types other than pointers and members are not "
134 "supported by Rust debug info parser");
140 if (Type.getSizeInBits() == 0) {
144 if (
auto BT = dyn_cast<DIBasicType>(&Type)) {
146 }
else if (
auto CT = dyn_cast<DICompositeType>(&Type)) {
148 }
else if (
auto DT = dyn_cast<DIDerivedType>(&Type)) {
151 assert(0 &&
"Types other than floating-points, integers, arrays, pointers, "
152 "slices, and structs are not supported by debug info parser");
158 if (type.getTag() == dwarf::DW_TAG_pointer_type) {
159 auto PTy = dyn_cast<DIDerivedType>(&type);
160 DIType *SubType = PTy->getBaseType();
161 if (
auto BTy = dyn_cast<DIBasicType>(SubType)) {
162 std::string name = BTy->getName().str();
TypeTree ShiftIndices(const llvm::DataLayout &dl, const int offset, const int maxSize, size_t addOffset=0) const
Replace mappings in the range in [offset, offset+maxSize] with those in.