| ... | @@ -2897,43 +2897,52 @@ fn updateConstInner( | ... | @@ -2897,43 +2897,52 @@ fn updateConstInner( |
| 2897 | const loaded_struct = ip.loadStructType(@"const"); | 2897 | const loaded_struct = ip.loadStructType(@"const"); |
| 2898 | const src_inst = loaded_struct.zir_index.resolveFull(ip).?; | 2898 | const src_inst = loaded_struct.zir_index.resolveFull(ip).?; |
| 2899 | const zf = zcu.fileByIndex(src_inst.file); | 2899 | const zf = zcu.fileByIndex(src_inst.file); |
| | 2900 | const is_empty = loaded_struct.captures.len == 0 and loaded_struct.field_types.len == 0; |
| 2900 | if (src_inst.inst == .main_struct_inst) { | 2901 | if (src_inst.inst == .main_struct_inst) { |
| 2901 | assert(loaded_struct.captures.len == 0); | 2902 | assert(loaded_struct.captures.len == 0); |
| 2902 | const ui = dwarf.getUnit(zf.mod.?); | 2903 | const ui = dwarf.getUnit(zf.mod.?); |
| 2903 | _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, src_inst.file); | 2904 | _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, src_inst.file); |
| 2904 | try dwarf.abbrevCode(di_nw, switch (loaded_struct.layout) { | 2905 | try dwarf.abbrevCode(di_nw, switch (loaded_struct.layout) { |
| 2905 | .auto => if (loaded_struct.field_types.len > 0) .file else .empty_file, | 2906 | .auto => if (is_empty) .empty_file else .file, |
| 2906 | .@"extern", .@"packed" => unreachable, | 2907 | .@"extern", .@"packed" => unreachable, |
| 2907 | }); | 2908 | }); |
| 2908 | try di_w.writeUleb128(@backingInt(fi)); | 2909 | try di_w.writeUleb128(@backingInt(fi)); |
| 2909 | try dwarf.strx(di_nw, loaded_struct.name.toSlice(ip)); | 2910 | try dwarf.strx(di_nw, loaded_struct.name.toSlice(ip)); |
| 2910 | } else if (loaded_struct.captures.len > 0 or loaded_struct.is_reified) { | 2911 | } else if (loaded_struct.captures.len > 0 or loaded_struct.is_reified) { |
| 2911 | try dwarf.abbrevCode(di_nw, if (loaded_struct.captures.len > 0 or | 2912 | try dwarf.abbrevCode(di_nw, switch (loaded_struct.name_nav) { |
| 2912 | loaded_struct.field_types.len > 0) switch (loaded_struct.layout) { | 2913 | else => if (is_empty) switch (loaded_struct.layout) { |
| 2913 | .auto, .@"extern" => .decl_instance_struct, | 2914 | .auto, .@"extern" => .decl_instance_empty_struct, |
| 2914 | .@"packed" => .decl_instance_packed_struct, | 2915 | .@"packed" => .decl_instance_empty_packed_struct, |
| 2915 | } else switch (loaded_struct.layout) { | 2916 | } else switch (loaded_struct.layout) { |
| 2916 | .auto, .@"extern" => .decl_instance_empty_struct, | 2917 | .auto, .@"extern" => .decl_instance_struct, |
| 2917 | .@"packed" => .decl_instance_empty_packed_struct, | 2918 | .@"packed" => .decl_instance_packed_struct, |
| | 2919 | }, |
| | 2920 | .none => if (is_empty) switch (loaded_struct.layout) { |
| | 2921 | .auto, .@"extern" => .type_decl_instance_empty_struct, |
| | 2922 | .@"packed" => .type_decl_instance_empty_packed_struct, |
| | 2923 | } else switch (loaded_struct.layout) { |
| | 2924 | .auto, .@"extern" => .type_decl_instance_struct, |
| | 2925 | .@"packed" => .type_decl_instance_packed_struct, |
| | 2926 | }, |
| 2918 | }); | 2927 | }); |
| 2919 | try dwarf.refType(pt, di_nw, .fromInterned(ip.namespacePtr( | 2928 | try dwarf.refType(pt, di_nw, .fromInterned(ip.namespacePtr( |
| 2920 | ip.namespacePtr(loaded_struct.namespace).parent.unwrap().?, | 2929 | ip.namespacePtr(loaded_struct.namespace).parent.unwrap().?, |
| 2921 | ).owner_type)); | 2930 | ).owner_type)); |
| 2922 | try dwarf.secOffset(di_nw, try dwarf.getConstDecl(pt, @"const"), 0); | 2931 | try dwarf.secOffset(di_nw, try dwarf.getConstDecl(pt, @"const"), 0); |
| | 2932 | if (loaded_struct.name_nav == .none) |
| | 2933 | try dwarf.strx(di_nw, loaded_struct.name.toSlice(ip)); |
| 2923 | } else if (loaded_struct.name_nav.unwrap()) |name_ni| { | 2934 | } else if (loaded_struct.name_nav.unwrap()) |name_ni| { |
| 2924 | const name_nav = ip.getNav(name_ni); | 2935 | const name_nav = ip.getNav(name_ni); |
| 2925 | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); | 2936 | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); |
| 2926 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( | 2937 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( |
| 2927 | name_nav.analysis.?.namespace, | 2938 | name_nav.analysis.?.namespace, |
| 2928 | ).owner_type); | 2939 | ).owner_type); |
| 2929 | try dwarf.abbrevCode(di_nw, if (loaded_struct.field_types.len > 0) | 2940 | try dwarf.abbrevCode(di_nw, if (is_empty) switch (loaded_struct.layout) { |
| 2930 | switch (loaded_struct.layout) { | | |
| 2931 | .auto, .@"extern" => .decl_struct, | | |
| 2932 | .@"packed" => .decl_packed_struct, | | |
| 2933 | } | | |
| 2934 | else switch (loaded_struct.layout) { | | |
| 2935 | .auto, .@"extern" => .decl_empty_struct, | 2941 | .auto, .@"extern" => .decl_empty_struct, |
| 2936 | .@"packed" => .decl_empty_packed_struct, | 2942 | .@"packed" => .decl_empty_packed_struct, |
| | 2943 | } else switch (loaded_struct.layout) { |
| | 2944 | .auto, .@"extern" => .decl_struct, |
| | 2945 | .@"packed" => .decl_packed_struct, |
| 2937 | }); | 2946 | }); |
| 2938 | try dwarf.secOffset(di_nw, parent_ni, 0); | 2947 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 2939 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); | 2948 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| ... | @@ -2945,14 +2954,12 @@ fn updateConstInner( | ... | @@ -2945,14 +2954,12 @@ fn updateConstInner( |
| 2945 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( | 2954 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( |
| 2946 | ip.namespacePtr(loaded_struct.namespace).parent.unwrap().?, | 2955 | ip.namespacePtr(loaded_struct.namespace).parent.unwrap().?, |
| 2947 | ).owner_type); | 2956 | ).owner_type); |
| 2948 | try dwarf.abbrevCode(di_nw, if (loaded_struct.field_types.len > 0) | 2957 | try dwarf.abbrevCode(di_nw, if (is_empty) switch (loaded_struct.layout) { |
| 2949 | switch (loaded_struct.layout) { | | |
| 2950 | .auto, .@"extern" => .type_decl_struct, | | |
| 2951 | .@"packed" => .type_decl_packed_struct, | | |
| 2952 | } | | |
| 2953 | else switch (loaded_struct.layout) { | | |
| 2954 | .auto, .@"extern" => .type_decl_empty_struct, | 2958 | .auto, .@"extern" => .type_decl_empty_struct, |
| 2955 | .@"packed" => .type_decl_empty_packed_struct, | 2959 | .@"packed" => .type_decl_empty_packed_struct, |
| | 2960 | } else switch (loaded_struct.layout) { |
| | 2961 | .auto, .@"extern" => .type_decl_struct, |
| | 2962 | .@"packed" => .type_decl_packed_struct, |
| 2956 | }); | 2963 | }); |
| 2957 | try dwarf.secOffset(di_nw, parent_ni, 0); | 2964 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 2958 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); | 2965 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| ... | @@ -3033,41 +3040,49 @@ fn updateConstInner( | ... | @@ -3033,41 +3040,49 @@ fn updateConstInner( |
| 3033 | } | 3040 | } |
| 3034 | }, | 3041 | }, |
| 3035 | } | 3042 | } |
| 3036 | if (loaded_struct.captures.len > 0 or loaded_struct.field_types.len > 0) | 3043 | if (!is_empty) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 3037 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); | | |
| 3038 | }, | 3044 | }, |
| 3039 | .union_type => { | 3045 | .union_type => { |
| 3040 | const loaded_union = ip.loadUnionType(@"const"); | 3046 | const loaded_union = ip.loadUnionType(@"const"); |
| 3041 | const loaded_tag = ip.loadEnumType(loaded_union.enum_tag_type); | 3047 | const loaded_tag = ip.loadEnumType(loaded_union.enum_tag_type); |
| 3042 | const zfi = loaded_union.zir_index.resolveFile(ip); | 3048 | const zfi = loaded_union.zir_index.resolveFile(ip); |
| 3043 | const zf = zcu.fileByIndex(zfi); | 3049 | const zf = zcu.fileByIndex(zfi); |
| | 3050 | const is_empty = loaded_union.captures.len == 0 and loaded_union.field_types.len == 0; |
| 3044 | if (loaded_union.captures.len > 0 or loaded_union.is_reified) { | 3051 | if (loaded_union.captures.len > 0 or loaded_union.is_reified) { |
| 3045 | try dwarf.abbrevCode(di_nw, if (loaded_union.captures.len > 0 or | 3052 | try dwarf.abbrevCode(di_nw, switch (loaded_union.name_nav) { |
| 3046 | loaded_union.field_types.len > 0) switch (loaded_union.layout) { | 3053 | else => if (is_empty) switch (loaded_union.layout) { |
| 3047 | .auto, .@"extern" => .decl_instance_union, | 3054 | .auto, .@"extern" => .decl_instance_empty_union, |
| 3048 | .@"packed" => .decl_instance_packed_union, | 3055 | .@"packed" => .decl_instance_empty_packed_union, |
| 3049 | } else switch (loaded_union.layout) { | 3056 | } else switch (loaded_union.layout) { |
| 3050 | .auto, .@"extern" => .decl_instance_empty_union, | 3057 | .auto, .@"extern" => .decl_instance_union, |
| 3051 | .@"packed" => .decl_instance_empty_packed_union, | 3058 | .@"packed" => .decl_instance_packed_union, |
| | 3059 | }, |
| | 3060 | .none => if (is_empty) switch (loaded_union.layout) { |
| | 3061 | .auto, .@"extern" => .type_decl_instance_empty_union, |
| | 3062 | .@"packed" => .type_decl_instance_empty_packed_union, |
| | 3063 | } else switch (loaded_union.layout) { |
| | 3064 | .auto, .@"extern" => .type_decl_instance_union, |
| | 3065 | .@"packed" => .type_decl_instance_packed_union, |
| | 3066 | }, |
| 3052 | }); | 3067 | }); |
| 3053 | try dwarf.refType(pt, di_nw, .fromInterned(ip.namespacePtr( | 3068 | try dwarf.refType(pt, di_nw, .fromInterned(ip.namespacePtr( |
| 3054 | ip.namespacePtr(loaded_union.namespace).parent.unwrap().?, | 3069 | ip.namespacePtr(loaded_union.namespace).parent.unwrap().?, |
| 3055 | ).owner_type)); | 3070 | ).owner_type)); |
| 3056 | try dwarf.secOffset(di_nw, try dwarf.getConstDecl(pt, @"const"), 0); | 3071 | try dwarf.secOffset(di_nw, try dwarf.getConstDecl(pt, @"const"), 0); |
| | 3072 | if (loaded_union.name_nav == .none) |
| | 3073 | try dwarf.strx(di_nw, loaded_union.name.toSlice(ip)); |
| 3057 | } else if (loaded_union.name_nav.unwrap()) |name_ni| { | 3074 | } else if (loaded_union.name_nav.unwrap()) |name_ni| { |
| 3058 | const name_nav = ip.getNav(name_ni); | 3075 | const name_nav = ip.getNav(name_ni); |
| 3059 | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); | 3076 | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); |
| 3060 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( | 3077 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( |
| 3061 | name_nav.analysis.?.namespace, | 3078 | name_nav.analysis.?.namespace, |
| 3062 | ).owner_type); | 3079 | ).owner_type); |
| 3063 | try dwarf.abbrevCode(di_nw, if (loaded_union.field_types.len > 0) | 3080 | try dwarf.abbrevCode(di_nw, if (is_empty) switch (loaded_union.layout) { |
| 3064 | switch (loaded_union.layout) { | | |
| 3065 | .auto, .@"extern" => .decl_union, | | |
| 3066 | .@"packed" => .decl_packed_union, | | |
| 3067 | } | | |
| 3068 | else switch (loaded_union.layout) { | | |
| 3069 | .auto, .@"extern" => .decl_empty_union, | 3081 | .auto, .@"extern" => .decl_empty_union, |
| 3070 | .@"packed" => .decl_empty_packed_union, | 3082 | .@"packed" => .decl_empty_packed_union, |
| | 3083 | } else switch (loaded_union.layout) { |
| | 3084 | .auto, .@"extern" => .decl_union, |
| | 3085 | .@"packed" => .decl_packed_union, |
| 3071 | }); | 3086 | }); |
| 3072 | try dwarf.secOffset(di_nw, parent_ni, 0); | 3087 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 3073 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); | 3088 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| ... | @@ -3079,14 +3094,12 @@ fn updateConstInner( | ... | @@ -3079,14 +3094,12 @@ fn updateConstInner( |
| 3079 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( | 3094 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( |
| 3080 | ip.namespacePtr(loaded_union.namespace).parent.unwrap().?, | 3095 | ip.namespacePtr(loaded_union.namespace).parent.unwrap().?, |
| 3081 | ).owner_type); | 3096 | ).owner_type); |
| 3082 | try dwarf.abbrevCode(di_nw, if (loaded_union.field_types.len > 0) | 3097 | try dwarf.abbrevCode(di_nw, if (is_empty) switch (loaded_union.layout) { |
| 3083 | switch (loaded_union.layout) { | | |
| 3084 | .auto, .@"extern" => .type_decl_union, | | |
| 3085 | .@"packed" => .type_decl_packed_union, | | |
| 3086 | } | | |
| 3087 | else switch (loaded_union.layout) { | | |
| 3088 | .auto, .@"extern" => .type_decl_empty_union, | 3098 | .auto, .@"extern" => .type_decl_empty_union, |
| 3089 | .@"packed" => .type_decl_empty_packed_union, | 3099 | .@"packed" => .type_decl_empty_packed_union, |
| | 3100 | } else switch (loaded_union.layout) { |
| | 3101 | .auto, .@"extern" => .type_decl_union, |
| | 3102 | .@"packed" => .type_decl_packed_union, |
| 3090 | }); | 3103 | }); |
| 3091 | try dwarf.secOffset(di_nw, parent_ni, 0); | 3104 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 3092 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); | 3105 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| ... | @@ -3169,26 +3182,30 @@ fn updateConstInner( | ... | @@ -3169,26 +3182,30 @@ fn updateConstInner( |
| 3169 | } | 3182 | } |
| 3170 | }, | 3183 | }, |
| 3171 | } | 3184 | } |
| 3172 | if (loaded_union.captures.len > 0 or loaded_union.field_types.len > 0) | 3185 | if (!is_empty) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 3173 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); | | |
| 3174 | }, | 3186 | }, |
| 3175 | .enum_type => { | 3187 | .enum_type => { |
| 3176 | const loaded_enum = ip.loadEnumType(@"const"); | 3188 | const loaded_enum = ip.loadEnumType(@"const"); |
| | 3189 | const is_empty = loaded_enum.captures.len == 0 and loaded_enum.field_names.len == 0; |
| 3177 | switch (loaded_enum.owner_union) { | 3190 | switch (loaded_enum.owner_union) { |
| 3178 | .none => { | 3191 | .none => { |
| 3179 | const zfi = loaded_enum.zir_index.unwrap().?.resolveFile(ip); | 3192 | const zfi = loaded_enum.zir_index.unwrap().?.resolveFile(ip); |
| 3180 | const zf = zcu.fileByIndex(zfi); | 3193 | const zf = zcu.fileByIndex(zfi); |
| 3181 | const zir = &zf.zir.?; | 3194 | const zir = &zf.zir.?; |
| 3182 | if (loaded_enum.captures.len > 0 or loaded_enum.is_reified) { | 3195 | if (loaded_enum.captures.len > 0 or loaded_enum.is_reified) { |
| 3183 | try dwarf.abbrevCode(di_nw, if (loaded_enum.captures.len > 0 or | 3196 | try dwarf.abbrevCode(di_nw, switch (loaded_enum.name_nav) { |
| 3184 | loaded_enum.field_names.len > 0) | 3197 | else => if (is_empty) .decl_instance_empty_enum else .decl_instance_enum, |
| 3185 | .decl_instance_enum | 3198 | .none => if (is_empty) |
| 3186 | else | 3199 | .type_decl_instance_empty_enum |
| 3187 | .decl_instance_empty_enum); | 3200 | else |
| | 3201 | .type_decl_instance_enum, |
| | 3202 | }); |
| 3188 | try dwarf.refType(pt, di_nw, .fromInterned(ip.namespacePtr( | 3203 | try dwarf.refType(pt, di_nw, .fromInterned(ip.namespacePtr( |
| 3189 | ip.namespacePtr(loaded_enum.namespace).parent.unwrap().?, | 3204 | ip.namespacePtr(loaded_enum.namespace).parent.unwrap().?, |
| 3190 | ).owner_type)); | 3205 | ).owner_type)); |
| 3191 | try dwarf.secOffset(di_nw, try dwarf.getConstDecl(pt, @"const"), 0); | 3206 | try dwarf.secOffset(di_nw, try dwarf.getConstDecl(pt, @"const"), 0); |
| | 3207 | if (loaded_enum.name_nav == .none) |
| | 3208 | try dwarf.strx(di_nw, loaded_enum.name.toSlice(ip)); |
| 3192 | } else if (loaded_enum.name_nav.unwrap()) |name_ni| { | 3209 | } else if (loaded_enum.name_nav.unwrap()) |name_ni| { |
| 3193 | const name_nav = ip.getNav(name_ni); | 3210 | const name_nav = ip.getNav(name_ni); |
| 3194 | const decl = zir.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); | 3211 | const decl = zir.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); |
| ... | @@ -3197,7 +3214,7 @@ fn updateConstInner( | ... | @@ -3197,7 +3214,7 @@ fn updateConstInner( |
| 3197 | ).owner_type); | 3214 | ).owner_type); |
| 3198 | try dwarf.abbrevCode( | 3215 | try dwarf.abbrevCode( |
| 3199 | di_nw, | 3216 | di_nw, |
| 3200 | if (loaded_enum.field_names.len > 0) .decl_enum else .decl_empty_enum, | 3217 | if (is_empty) .decl_empty_enum else .decl_enum, |
| 3201 | ); | 3218 | ); |
| 3202 | try dwarf.secOffset(di_nw, parent_ni, 0); | 3219 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 3203 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); | 3220 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| ... | @@ -3209,10 +3226,10 @@ fn updateConstInner( | ... | @@ -3209,10 +3226,10 @@ fn updateConstInner( |
| 3209 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( | 3226 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( |
| 3210 | ip.namespacePtr(loaded_enum.namespace).parent.unwrap().?, | 3227 | ip.namespacePtr(loaded_enum.namespace).parent.unwrap().?, |
| 3211 | ).owner_type); | 3228 | ).owner_type); |
| 3212 | try dwarf.abbrevCode(di_nw, if (loaded_enum.field_names.len > 0) | 3229 | try dwarf.abbrevCode( |
| 3213 | .type_decl_enum | 3230 | di_nw, |
| 3214 | else | 3231 | if (is_empty) .type_decl_empty_enum else .type_decl_enum, |
| 3215 | .type_decl_empty_enum); | 3232 | ); |
| 3216 | try dwarf.secOffset(di_nw, parent_ni, 0); | 3233 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 3217 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); | 3234 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 3218 | try di_w.writeUleb128(decl.src_column + 1); | 3235 | try di_w.writeUleb128(decl.src_column + 1); |
| ... | @@ -3220,10 +3237,10 @@ fn updateConstInner( | ... | @@ -3220,10 +3237,10 @@ fn updateConstInner( |
| 3220 | } | 3237 | } |
| 3221 | }, | 3238 | }, |
| 3222 | else => { | 3239 | else => { |
| 3223 | try dwarf.abbrevCode(di_nw, if (loaded_enum.field_names.len > 0) | 3240 | try dwarf.abbrevCode( |
| 3224 | .generated_enum_type | 3241 | di_nw, |
| 3225 | else | 3242 | if (is_empty) .generated_empty_enum_type else .generated_enum_type, |
| 3226 | .generated_empty_enum_type); | 3243 | ); |
| 3227 | try dwarf.strx(di_nw, loaded_enum.fqn.toSlice(ip)); | 3244 | try dwarf.strx(di_nw, loaded_enum.fqn.toSlice(ip)); |
| 3228 | }, | 3245 | }, |
| 3229 | } | 3246 | } |
| ... | @@ -3234,8 +3251,7 @@ fn updateConstInner( | ... | @@ -3234,8 +3251,7 @@ fn updateConstInner( |
| 3234 | try dwarf.enumConstValue(di_w, loaded_enum, field_index); | 3251 | try dwarf.enumConstValue(di_w, loaded_enum, field_index); |
| 3235 | try dwarf.strx(di_nw, loaded_enum.field_names.get(ip)[field_index].toSlice(ip)); | 3252 | try dwarf.strx(di_nw, loaded_enum.field_names.get(ip)[field_index].toSlice(ip)); |
| 3236 | } | 3253 | } |
| 3237 | if (loaded_enum.captures.len > 0 or loaded_enum.field_names.len > 0) | 3254 | if (!is_empty) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 3238 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); | | |
| 3239 | }, | 3255 | }, |
| 3240 | // no defined size, so lowered the same as incomplete struct types | 3256 | // no defined size, so lowered the same as incomplete struct types |
| 3241 | .opaque_type => return dwarf.updateConstIncompleteInner(pt, di_nw, @"const"), | 3257 | .opaque_type => return dwarf.updateConstIncompleteInner(pt, di_nw, @"const"), |
| ... | @@ -4151,7 +4167,7 @@ fn genDeclInner( | ... | @@ -4151,7 +4167,7 @@ fn genDeclInner( |
| 4151 | done: switch (instance) { | 4167 | done: switch (instance) { |
| 4152 | .none => unreachable, | 4168 | .none => unreachable, |
| 4153 | .@"const" => |@"const"| { | 4169 | .@"const" => |@"const"| { |
| 4154 | const kind: enum { @"struct", @"union", @"enum" }, const zf, const src_line, const src_column, const capture_names, const captures, const name, const maybe_name_nav, const namespace = container: switch (ip.indexToKey(instance.@"const")) { | 4170 | const kind: enum { @"struct", @"union", @"enum" }, const zf, const src_line, const src_column, const capture_names, const captures, const maybe_name_nav, const namespace = container: switch (ip.indexToKey(instance.@"const")) { |
| 4155 | else => unreachable, | 4171 | else => unreachable, |
| 4156 | .struct_type => { | 4172 | .struct_type => { |
| 4157 | const loaded_struct = ip.loadStructType(@"const"); | 4173 | const loaded_struct = ip.loadStructType(@"const"); |
| ... | @@ -4200,7 +4216,6 @@ fn genDeclInner( | ... | @@ -4200,7 +4216,6 @@ fn genDeclInner( |
| 4200 | src_column, | 4216 | src_column, |
| 4201 | capture_names, | 4217 | capture_names, |
| 4202 | loaded_struct.captures, | 4218 | loaded_struct.captures, |
| 4203 | loaded_struct.name, | | |
| 4204 | loaded_struct.name_nav, | 4219 | loaded_struct.name_nav, |
| 4205 | loaded_struct.namespace, | 4220 | loaded_struct.namespace, |
| 4206 | }; | 4221 | }; |
| ... | @@ -4238,7 +4253,6 @@ fn genDeclInner( | ... | @@ -4238,7 +4253,6 @@ fn genDeclInner( |
| 4238 | src_column, | 4253 | src_column, |
| 4239 | capture_names, | 4254 | capture_names, |
| 4240 | loaded_union.captures, | 4255 | loaded_union.captures, |
| 4241 | loaded_union.name, | | |
| 4242 | loaded_union.name_nav, | 4256 | loaded_union.name_nav, |
| 4243 | loaded_union.namespace, | 4257 | loaded_union.namespace, |
| 4244 | }; | 4258 | }; |
| ... | @@ -4276,7 +4290,6 @@ fn genDeclInner( | ... | @@ -4276,7 +4290,6 @@ fn genDeclInner( |
| 4276 | src_column, | 4290 | src_column, |
| 4277 | capture_names, | 4291 | capture_names, |
| 4278 | loaded_enum.captures, | 4292 | loaded_enum.captures, |
| 4279 | loaded_enum.name, | | |
| 4280 | loaded_enum.name_nav, | 4293 | loaded_enum.name_nav, |
| 4281 | loaded_enum.namespace, | 4294 | loaded_enum.namespace, |
| 4282 | }; | 4295 | }; |
| ... | @@ -4296,7 +4309,6 @@ fn genDeclInner( | ... | @@ -4296,7 +4309,6 @@ fn genDeclInner( |
| 4296 | decl.src_column, | 4309 | decl.src_column, |
| 4297 | decl.capture_names, | 4310 | decl.capture_names, |
| 4298 | loaded_opaque.captures, | 4311 | loaded_opaque.captures, |
| 4299 | loaded_opaque.name, | | |
| 4300 | loaded_opaque.name_nav, | 4312 | loaded_opaque.name_nav, |
| 4301 | loaded_opaque.namespace, | 4313 | loaded_opaque.namespace, |
| 4302 | }; | 4314 | }; |
| ... | @@ -4340,7 +4352,7 @@ fn genDeclInner( | ... | @@ -4340,7 +4352,7 @@ fn genDeclInner( |
| 4340 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); | 4352 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 4341 | try di_w.writeUleb128(decl.src_column + 1); | 4353 | try di_w.writeUleb128(decl.src_column + 1); |
| 4342 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); | 4354 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| 4343 | try dwarf.strx(di_nw, name.toSlice(ip)); | 4355 | try dwarf.strx(di_nw, name_nav.name.toSlice(ip)); |
| 4344 | } else { | 4356 | } else { |
| 4345 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( | 4357 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( |
| 4346 | ip.namespacePtr(namespace).parent.unwrap().?, | 4358 | ip.namespacePtr(namespace).parent.unwrap().?, |
| ... | @@ -4357,7 +4369,6 @@ fn genDeclInner( | ... | @@ -4357,7 +4369,6 @@ fn genDeclInner( |
| 4357 | try dwarf.secOffset(di_nw, parent_ni, 0); | 4369 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 4358 | try di_w.writeInt(u32, src_line + 1, dwarf.endian); | 4370 | try di_w.writeInt(u32, src_line + 1, dwarf.endian); |
| 4359 | try di_w.writeUleb128(src_column + 1); | 4371 | try di_w.writeUleb128(src_column + 1); |
| 4360 | try dwarf.strx(di_nw, name.toSlice(ip)); | | |
| 4361 | } | 4372 | } |
| 4362 | for (capture_names, captures.get(ip)) |capture_name, capture| { | 4373 | for (capture_names, captures.get(ip)) |capture_name, capture| { |
| 4363 | try dwarf.abbrevCode(di_nw, .capture_specification); | 4374 | try dwarf.abbrevCode(di_nw, .capture_specification); |
| ... | @@ -4409,9 +4420,12 @@ pub fn updateLineNumber( | ... | @@ -4409,9 +4420,12 @@ pub fn updateLineNumber( |
| 4409 | ) void { | 4420 | ) void { |
| 4410 | const di = dwarf.getDeclIfExists(inst) orelse return; | 4421 | const di = dwarf.getDeclIfExists(inst) orelse return; |
| 4411 | const decl_ni = di.get(dwarf).debug_info_ni.unwrap().?; | 4422 | const decl_ni = di.get(dwarf).debug_info_ni.unwrap().?; |
| | 4423 | comptime assert(AbbrevCode.common_decl_attrs[0][1] == .ref_addr); |
| | 4424 | comptime assert(AbbrevCode.common_decl_attrs[1][0] == .decl_line); |
| | 4425 | comptime assert(AbbrevCode.common_decl_attrs[1][1] == .data4); |
| 4412 | std.mem.writeInt( | 4426 | std.mem.writeInt( |
| 4413 | u32, | 4427 | u32, |
| 4414 | decl_ni.slice(mf)[AbbrevCode.decl_size..][0..4], | 4428 | decl_ni.slice(mf)[AbbrevCode.decl_size + dwarf.secOffsetSize() ..][0..4], |
| 4415 | line + 1, | 4429 | line + 1, |
| 4416 | dwarf.endian, | 4430 | dwarf.endian, |
| 4417 | ); | 4431 | ); |
| ... | @@ -4806,18 +4820,28 @@ pub const AbbrevCode = enum { | ... | @@ -4806,18 +4820,28 @@ pub const AbbrevCode = enum { |
| 4806 | decl_instance_incomplete_enum, | 4820 | decl_instance_incomplete_enum, |
| 4807 | decl_instance_empty_enum, | 4821 | decl_instance_empty_enum, |
| 4808 | decl_instance_enum, | 4822 | decl_instance_enum, |
| | 4823 | type_decl_instance_empty_enum, |
| | 4824 | type_decl_instance_enum, |
| 4809 | decl_instance_empty_incomplete_struct, | 4825 | decl_instance_empty_incomplete_struct, |
| 4810 | decl_instance_incomplete_struct, | 4826 | decl_instance_incomplete_struct, |
| 4811 | decl_instance_empty_struct, | 4827 | decl_instance_empty_struct, |
| 4812 | decl_instance_struct, | 4828 | decl_instance_struct, |
| | 4829 | type_decl_instance_empty_struct, |
| | 4830 | type_decl_instance_struct, |
| 4813 | decl_instance_empty_packed_struct, | 4831 | decl_instance_empty_packed_struct, |
| 4814 | decl_instance_packed_struct, | 4832 | decl_instance_packed_struct, |
| | 4833 | type_decl_instance_empty_packed_struct, |
| | 4834 | type_decl_instance_packed_struct, |
| 4815 | decl_instance_empty_incomplete_union, | 4835 | decl_instance_empty_incomplete_union, |
| 4816 | decl_instance_incomplete_union, | 4836 | decl_instance_incomplete_union, |
| 4817 | decl_instance_empty_union, | 4837 | decl_instance_empty_union, |
| 4818 | decl_instance_union, | 4838 | decl_instance_union, |
| | 4839 | type_decl_instance_empty_union, |
| | 4840 | type_decl_instance_union, |
| 4819 | decl_instance_empty_packed_union, | 4841 | decl_instance_empty_packed_union, |
| 4820 | decl_instance_packed_union, | 4842 | decl_instance_packed_union, |
| | 4843 | type_decl_instance_empty_packed_union, |
| | 4844 | type_decl_instance_packed_union, |
| 4821 | decl_instance_type, | 4845 | decl_instance_type, |
| 4822 | decl_instance_const, | 4846 | decl_instance_const, |
| 4823 | decl_instance_const_fully_runtime, | 4847 | decl_instance_const_fully_runtime, |
| ... | @@ -4926,29 +4950,31 @@ pub const AbbrevCode = enum { | ... | @@ -4926,29 +4950,31 @@ pub const AbbrevCode = enum { |
| 4926 | DeclValEnum(DW.AT), | 4950 | DeclValEnum(DW.AT), |
| 4927 | DeclValEnum(DW.FORM), | 4951 | DeclValEnum(DW.FORM), |
| 4928 | }; | 4952 | }; |
| 4929 | const decl_attrs = &[_]Attr{ | 4953 | const common_decl_attrs = &[_]Attr{ |
| 4930 | .{ .ZIG_parent, .ref_addr }, | 4954 | .{ .ZIG_parent, .ref_addr }, |
| 4931 | .{ .decl_line, .data4 }, | 4955 | .{ .decl_line, .data4 }, |
| 4932 | .{ .decl_column, .udata }, | 4956 | .{ .decl_column, .udata }, |
| | 4957 | }; |
| | 4958 | const decl_attrs = common_decl_attrs ++ .{ |
| 4933 | .{ .accessibility, .data1 }, | 4959 | .{ .accessibility, .data1 }, |
| 4934 | .{ .name, .strx }, | 4960 | .{ .name, .strx }, |
| 4935 | }; | 4961 | }; |
| 4936 | const type_decl_attrs = &[_]Attr{ | 4962 | const type_decl_attrs = common_decl_attrs ++ .{ |
| 4937 | .{ .ZIG_parent, .ref_addr }, | | |
| 4938 | .{ .decl_line, .data4 }, | | |
| 4939 | .{ .decl_column, .udata }, | | |
| 4940 | .{ .name, .strx }, | 4963 | .{ .name, .strx }, |
| 4941 | }; | 4964 | }; |
| 4942 | const decl_specification_attrs = decl_attrs ++ &[_]Attr{ | 4965 | const decl_specification_attrs = decl_attrs ++ &[_]Attr{ |
| 4943 | .{ .declaration, .flag_present }, | 4966 | .{ .declaration, .flag_present }, |
| 4944 | }; | 4967 | }; |
| 4945 | const type_decl_specification_attrs = type_decl_attrs ++ &[_]Attr{ | 4968 | const type_decl_specification_attrs = common_decl_attrs ++ &[_]Attr{ |
| 4946 | .{ .declaration, .flag_present }, | 4969 | .{ .declaration, .flag_present }, |
| 4947 | }; | 4970 | }; |
| 4948 | const decl_instance_attrs = &[_]Attr{ | 4971 | const decl_instance_attrs = &[_]Attr{ |
| 4949 | .{ .ZIG_parent, .ref_addr }, | 4972 | .{ .ZIG_parent, .ref_addr }, |
| 4950 | .{ .specification, .ref_addr }, | 4973 | .{ .specification, .ref_addr }, |
| 4951 | }; | 4974 | }; |
| | 4975 | const type_decl_instance_attrs = decl_instance_attrs ++ .{ |
| | 4976 | .{ .name, .strx }, |
| | 4977 | }; |
| 4952 | | 4978 | |
| 4953 | const abbrevs = std.EnumArray(AbbrevCode, struct { | 4979 | const abbrevs = std.EnumArray(AbbrevCode, struct { |
| 4954 | tag: DeclValEnum(DW.TAG), | 4980 | tag: DeclValEnum(DW.TAG), |
| ... | @@ -5367,6 +5393,19 @@ pub const AbbrevCode = enum { | ... | @@ -5367,6 +5393,19 @@ pub const AbbrevCode = enum { |
| 5367 | .{ .type, .ref_addr }, | 5393 | .{ .type, .ref_addr }, |
| 5368 | }, | 5394 | }, |
| 5369 | }, | 5395 | }, |
| | 5396 | .type_decl_instance_empty_enum = .{ |
| | 5397 | .tag = .enumeration_type, |
| | 5398 | .attrs = type_decl_instance_attrs ++ .{ |
| | 5399 | .{ .type, .ref_addr }, |
| | 5400 | }, |
| | 5401 | }, |
| | 5402 | .type_decl_instance_enum = .{ |
| | 5403 | .tag = .enumeration_type, |
| | 5404 | .children = true, |
| | 5405 | .attrs = type_decl_instance_attrs ++ .{ |
| | 5406 | .{ .type, .ref_addr }, |
| | 5407 | }, |
| | 5408 | }, |
| 5370 | .decl_instance_empty_incomplete_struct = .{ | 5409 | .decl_instance_empty_incomplete_struct = .{ |
| 5371 | .tag = .structure_type, | 5410 | .tag = .structure_type, |
| 5372 | .attrs = decl_instance_attrs, | 5411 | .attrs = decl_instance_attrs, |
| ... | @@ -5391,6 +5430,21 @@ pub const AbbrevCode = enum { | ... | @@ -5391,6 +5430,21 @@ pub const AbbrevCode = enum { |
| 5391 | .{ .alignment, .udata }, | 5430 | .{ .alignment, .udata }, |
| 5392 | }, | 5431 | }, |
| 5393 | }, | 5432 | }, |
| | 5433 | .type_decl_instance_empty_struct = .{ |
| | 5434 | .tag = .structure_type, |
| | 5435 | .attrs = type_decl_instance_attrs ++ .{ |
| | 5436 | .{ .byte_size, .udata }, |
| | 5437 | .{ .alignment, .udata }, |
| | 5438 | }, |
| | 5439 | }, |
| | 5440 | .type_decl_instance_struct = .{ |
| | 5441 | .tag = .structure_type, |
| | 5442 | .children = true, |
| | 5443 | .attrs = type_decl_instance_attrs ++ .{ |
| | 5444 | .{ .byte_size, .udata }, |
| | 5445 | .{ .alignment, .udata }, |
| | 5446 | }, |
| | 5447 | }, |
| 5394 | .decl_instance_empty_packed_struct = .{ | 5448 | .decl_instance_empty_packed_struct = .{ |
| 5395 | .tag = .structure_type, | 5449 | .tag = .structure_type, |
| 5396 | .attrs = decl_instance_attrs ++ .{ | 5450 | .attrs = decl_instance_attrs ++ .{ |
| ... | @@ -5404,6 +5458,19 @@ pub const AbbrevCode = enum { | ... | @@ -5404,6 +5458,19 @@ pub const AbbrevCode = enum { |
| 5404 | .{ .type, .ref_addr }, | 5458 | .{ .type, .ref_addr }, |
| 5405 | }, | 5459 | }, |
| 5406 | }, | 5460 | }, |
| | 5461 | .type_decl_instance_empty_packed_struct = .{ |
| | 5462 | .tag = .structure_type, |
| | 5463 | .attrs = type_decl_instance_attrs ++ .{ |
| | 5464 | .{ .type, .ref_addr }, |
| | 5465 | }, |
| | 5466 | }, |
| | 5467 | .type_decl_instance_packed_struct = .{ |
| | 5468 | .tag = .structure_type, |
| | 5469 | .children = true, |
| | 5470 | .attrs = type_decl_instance_attrs ++ .{ |
| | 5471 | .{ .type, .ref_addr }, |
| | 5472 | }, |
| | 5473 | }, |
| 5407 | .decl_instance_empty_incomplete_union = .{ | 5474 | .decl_instance_empty_incomplete_union = .{ |
| 5408 | .tag = .union_type, | 5475 | .tag = .union_type, |
| 5409 | .attrs = decl_instance_attrs, | 5476 | .attrs = decl_instance_attrs, |
| ... | @@ -5428,6 +5495,21 @@ pub const AbbrevCode = enum { | ... | @@ -5428,6 +5495,21 @@ pub const AbbrevCode = enum { |
| 5428 | .{ .alignment, .udata }, | 5495 | .{ .alignment, .udata }, |
| 5429 | }, | 5496 | }, |
| 5430 | }, | 5497 | }, |
| | 5498 | .type_decl_instance_empty_union = .{ |
| | 5499 | .tag = .union_type, |
| | 5500 | .attrs = type_decl_instance_attrs ++ .{ |
| | 5501 | .{ .byte_size, .udata }, |
| | 5502 | .{ .alignment, .udata }, |
| | 5503 | }, |
| | 5504 | }, |
| | 5505 | .type_decl_instance_union = .{ |
| | 5506 | .tag = .union_type, |
| | 5507 | .children = true, |
| | 5508 | .attrs = type_decl_instance_attrs ++ .{ |
| | 5509 | .{ .byte_size, .udata }, |
| | 5510 | .{ .alignment, .udata }, |
| | 5511 | }, |
| | 5512 | }, |
| 5431 | .decl_instance_empty_packed_union = .{ | 5513 | .decl_instance_empty_packed_union = .{ |
| 5432 | .tag = .union_type, | 5514 | .tag = .union_type, |
| 5433 | .attrs = decl_instance_attrs ++ .{ | 5515 | .attrs = decl_instance_attrs ++ .{ |
| ... | @@ -5441,6 +5523,19 @@ pub const AbbrevCode = enum { | ... | @@ -5441,6 +5523,19 @@ pub const AbbrevCode = enum { |
| 5441 | .{ .type, .ref_addr }, | 5523 | .{ .type, .ref_addr }, |
| 5442 | }, | 5524 | }, |
| 5443 | }, | 5525 | }, |
| | 5526 | .type_decl_instance_empty_packed_union = .{ |
| | 5527 | .tag = .union_type, |
| | 5528 | .attrs = type_decl_instance_attrs ++ .{ |
| | 5529 | .{ .type, .ref_addr }, |
| | 5530 | }, |
| | 5531 | }, |
| | 5532 | .type_decl_instance_packed_union = .{ |
| | 5533 | .tag = .union_type, |
| | 5534 | .children = true, |
| | 5535 | .attrs = type_decl_instance_attrs ++ .{ |
| | 5536 | .{ .type, .ref_addr }, |
| | 5537 | }, |
| | 5538 | }, |
| 5444 | .decl_instance_type = .{ | 5539 | .decl_instance_type = .{ |
| 5445 | .tag = .imported_declaration, | 5540 | .tag = .imported_declaration, |
| 5446 | .attrs = decl_instance_attrs ++ .{ | 5541 | .attrs = decl_instance_attrs ++ .{ |