Skip to content

Commit 196065f

Browse files
committed
Merge branch 'topic/more-anonymous-types' into 'master'
Omit names from artificial types See merge request eng/toolchain/gnat-llvm!368
2 parents d8e718f + 4571ee6 commit 196065f

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

llvm-interface/gnatllvm-debuginfo.adb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,13 @@ package body GNATLLVM.DebugInfo is
248248
function Get_Possibly_Local_Name (E : Entity_Id) return String is
249249
S : constant Metadata_T := Get_Scope_For (E);
250250
begin
251+
-- Most artificial types should be nameless. The only
252+
-- exception here is that there are some types that LLVM does
253+
-- not allow to be nameless; these are handled specially at the
254+
-- point at which such types are built.
255+
if not Comes_From_Source (E) and then Sloc (E) /= Standard_Location then
256+
return "";
257+
end if;
251258
if S = No_Metadata_T or not Types_Can_Have_Function_Scope then
252259
return Get_Name (E);
253260
end if;
@@ -867,7 +874,9 @@ package body GNATLLVM.DebugInfo is
867874
E_Index : Opt_N_Is_Index_Id := First_Index (Array_TE);
868875
begin
869876
if Is_Unconstrained_Array (Array_TE) then
870-
return DI_Create_Unspecified_Type (Name);
877+
-- LLVM does not allow a nameless unspecified type, so use
878+
-- the original name in this instance.
879+
return DI_Create_Unspecified_Type (Get_Name (Array_TE));
871880
end if;
872881

873882
-- For arrays, get the component type's data.
@@ -890,7 +899,9 @@ package body GNATLLVM.DebugInfo is
890899
Index_Type, High_Bound (E_Range));
891900
begin
892901
if Low_Exp = No_Metadata_T or else High_Exp = No_Metadata_T then
893-
return DI_Create_Unspecified_Type (Name);
902+
-- LLVM does not allow a nameless unspecified type, so use
903+
-- the original name in this instance.
904+
return DI_Create_Unspecified_Type (Get_Name (Array_TE));
894905
end if;
895906
if J = 0 and then Component_Size (Array_TE) /= Esize (Comp_TE) then
896907
Stride := Const_64_As_Metadata (Component_Size (Array_TE));

llvm-interface/gnatllvm-records-debug.adb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -316,23 +316,25 @@ package body GNATLLVM.Records.Debug is
316316
return Get_Debug_Metadata (Original_Type);
317317
end if;
318318

319-
-- A type might be self-referential. For example, a
320-
-- record may have a member whose type refers back to the
321-
-- same record type. To handle this case, we construct a
322-
-- empty composite type and record it; then later we
323-
-- update the members of the type.
319+
-- A type might be self-referential. For example, a record may
320+
-- have a member whose type refers back to the same record
321+
-- type. To handle this case, we construct a empty composite
322+
-- type and record it; then later we update the members of the
323+
-- type. Note that we pass a unique identifier here; that
324+
-- prevents LLVM from reusing an existing type in the case that
325+
-- this composite is nameless.
324326
if Is_Unchecked_Union (TE) then
325327
Result := DI_Create_Union_Type
326328
(Debug_Scope, Name,
327329
Get_Debug_File_Node (Get_Source_File_Index (S)),
328330
Get_Physical_Line_Number (S), Size, Align, DI_Flag_Zero,
329-
Empty_Fields, 0, "");
331+
Empty_Fields, 0, Name);
330332
else
331333
Result := DI_Create_Struct_Type
332334
(Debug_Scope, Name,
333335
Get_Debug_File_Node (Get_Source_File_Index (S)),
334336
Get_Physical_Line_Number (S), Size, Align, DI_Flag_Zero,
335-
No_Metadata_T, Empty_Fields, 0, No_Metadata_T, "");
337+
No_Metadata_T, Empty_Fields, 0, No_Metadata_T, Name);
336338
end if;
337339

338340
Set_Debug_Metadata (TE, Result);

0 commit comments

Comments
 (0)