Răsfoiți Sursa

llvmdbg: handle nil in more places

"void" is represented as "null" in LLVM debug information, which we represent
by nil
Jonas Maebe 3 ani în urmă
părinte
comite
e865ab4c3a
2 a modificat fișierele cu 16 adăugiri și 4 ștergeri
  1. 4 1
      compiler/llvm/aasmllvmmetadata.pas
  2. 12 3
      compiler/llvm/dbgllvm.pas

+ 4 - 1
compiler/llvm/aasmllvmmetadata.pas

@@ -199,7 +199,10 @@ implementation
 
   function llvm_getmetadatareftypedconst(metadata: tai_llvmbasemetadatanode): tai_simpletypedconst;
     begin
-      result:=tai_simpletypedconst.create(llvm_metadatatype, tai_llvmmetadatareftypedconst.create(metadata));
+      if assigned(metadata) then
+        result:=tai_simpletypedconst.create(llvm_metadatatype, tai_llvmmetadatareftypedconst.create(metadata))
+      else
+        result:=nil
     end;
 
   function llvm_constrainedexceptmodestring: ansistring;

+ 12 - 3
compiler/llvm/dbgllvm.pas

@@ -366,7 +366,10 @@ implementation
 
     function TDebugInfoLLVM.def_meta_node(def: tdef): tai_llvmspecialisedmetadatanode;
       begin
-        result:=tai_llvmspecialisedmetadatanode(get_def_metatai(def)^.HashSetItem.Data);
+        if not is_void(def) then
+          result:=tai_llvmspecialisedmetadatanode(get_def_metatai(def)^.HashSetItem.Data)
+        else
+          result:=nil;
       end;
 
     function TDebugInfoLLVM.def_meta_ref(def: tdef): tai_simpletypedconst;
@@ -626,6 +629,10 @@ implementation
         ordtype: tordtype;
         dinode: tai_llvmspecialisedmetadatanode;
       begin
+        { nothing, must be referenced as "null" in the using declaration }
+        if is_void(def) then
+          exit;
+
         ordtype:=def.ordtype;
         if ordtype=customint then
           ordtype:=range_to_basetype(def.low,def.high);
@@ -657,8 +664,7 @@ implementation
             end;
           uvoid :
             begin
-              { nothing, must be referenced as "null" in the using declaration }
-              internalerror(2021111501);
+              { checked above }
             end;
           uchar,
           uwidechar :
@@ -1110,6 +1116,9 @@ implementation
         if def.typ=procdef then
           exit;
 
+        if is_void(def) then
+          exit;
+
         refdinode:=def_meta_node(def);
 
         if is_objc_class_or_protocol(def) then