2
0
Эх сурвалжийг харах

Always try to present file/line information for generics even if no source is available or the unit was compiled as release unit. This allows IDE like Lazarus to correctly navigate to an error or warning even if the unit containing the generic was compiled as a release unit.

* pscanner.pas, tscannerfile.replaytoken: remove the checks for "sources_avail" and always update the read file/line information 
* fppu.pas, tppumodule.readsourcefiles: always load at least the filenames which were used when compiling the unit from the ppu file, so that file/line information will be correctly shown, but don't touch the "sources_avail" flag of the tppumodule

git-svn-id: trunk@21657 -
svenbarth 13 жил өмнө
parent
commit
f90e686be2
2 өөрчлөгдсөн 64 нэмэгдсэн , 84 устгасан
  1. 64 63
      compiler/fppu.pas
  2. 0 21
      compiler/scanner.pas

+ 64 - 63
compiler/fppu.pas

@@ -719,8 +719,6 @@ var
         hp            : tinputfile;
       begin
         sources_avail:=(flags and uf_release) = 0;
-        if not sources_avail then
-          exit;
         is_main:=true;
         main_dir:='';
         while not ppufile.endofentry do
@@ -728,73 +726,76 @@ var
            hs:=ppufile.getstring;
            orgfiletime:=ppufile.getlongint;
            temp_dir:='';
-           if (flags and uf_in_library)<>0 then
-            begin
-              sources_avail:=false;
-              temp:=' library';
-            end
-           else if pos('Macro ',hs)=1 then
-            begin
-              { we don't want to find this file }
-              { but there is a problem with file indexing !! }
-              temp:='';
-            end
-           else
-            begin
-              { check the date of the source files:
-                 1 path of ppu
-                 2 path of main source
-                 3 current dir
-                 4 include/unit path }
-              Source_Time:=GetNamedFileTime(path+hs);
-              found:=false;
-              if Source_Time<>-1 then
-                hs:=path+hs
-              else
-               if not(is_main) then
+           if sources_avail then
+             begin
+               if (flags and uf_in_library)<>0 then
                 begin
-                  Source_Time:=GetNamedFileTime(main_dir+hs);
-                  if Source_Time<>-1 then
-                    hs:=main_dir+hs;
-                end;
-              if Source_Time=-1 then
-                Source_Time:=GetNamedFileTime(hs);
-              if (Source_Time=-1) then
+                  sources_avail:=false;
+                  temp:=' library';
+                end
+               else if pos('Macro ',hs)=1 then
                 begin
-                  if is_main then
-                    found:=unitsearchpath.FindFile(hs,true,temp_dir)
-                  else
-                    found:=includesearchpath.FindFile(hs,true,temp_dir);
-                  if found then
-                   begin
-                     Source_Time:=GetNamedFileTime(temp_dir);
-                     if Source_Time<>-1 then
-                      hs:=temp_dir;
-                   end;
-                end;
-              if Source_Time<>-1 then
+                  { we don't want to find this file }
+                  { but there is a problem with file indexing !! }
+                  temp:='';
+                end
+               else
                 begin
-                  if is_main then
-                    main_dir:=ExtractFilePath(hs);
-                  temp:=' time '+filetimestring(source_time);
-                  if (orgfiletime<>-1) and
-                     (source_time<>orgfiletime) then
+                  { check the date of the source files:
+                     1 path of ppu
+                     2 path of main source
+                     3 current dir
+                     4 include/unit path }
+                  Source_Time:=GetNamedFileTime(path+hs);
+                  found:=false;
+                  if Source_Time<>-1 then
+                    hs:=path+hs
+                  else
+                   if not(is_main) then
                     begin
-                      do_compile:=true;
-                      recompile_reason:=rr_sourcenewer;
-                      Message2(unit_u_source_modified,hs,ppufilename,@queuecomment);
-                      temp:=temp+' *';
+                      Source_Time:=GetNamedFileTime(main_dir+hs);
+                      if Source_Time<>-1 then
+                        hs:=main_dir+hs;
                     end;
-                end
-              else
-                begin
-                  sources_avail:=false;
-                  temp:=' not found';
+                  if Source_Time=-1 then
+                    Source_Time:=GetNamedFileTime(hs);
+                  if (Source_Time=-1) then
+                    begin
+                      if is_main then
+                        found:=unitsearchpath.FindFile(hs,true,temp_dir)
+                      else
+                        found:=includesearchpath.FindFile(hs,true,temp_dir);
+                      if found then
+                       begin
+                         Source_Time:=GetNamedFileTime(temp_dir);
+                         if Source_Time<>-1 then
+                          hs:=temp_dir;
+                       end;
+                    end;
+                  if Source_Time<>-1 then
+                    begin
+                      if is_main then
+                        main_dir:=ExtractFilePath(hs);
+                      temp:=' time '+filetimestring(source_time);
+                      if (orgfiletime<>-1) and
+                         (source_time<>orgfiletime) then
+                        begin
+                          do_compile:=true;
+                          recompile_reason:=rr_sourcenewer;
+                          Message2(unit_u_source_modified,hs,ppufilename,@queuecomment);
+                          temp:=temp+' *';
+                        end;
+                    end
+                  else
+                    begin
+                      sources_avail:=false;
+                      temp:=' not found';
+                    end;
+                  hp:=tdosinputfile.create(hs);
+                  { the indexing is wrong here PM }
+                  sourcefiles.register_file(hp);
                 end;
-              hp:=tdosinputfile.create(hs);
-              { the indexing is wrong here PM }
-              sourcefiles.register_file(hp);
-            end;
+             end;
            if is_main then
              begin
                mainsource:=hs;

+ 0 - 21
compiler/scanner.pas

@@ -2684,11 +2684,6 @@ In case not, the value returned can be arbitrary.
                 if (ord(specialtoken) and $80)<>0 then
                   begin
                       current_tokenpos.column:=ord(specialtoken) and $7f;
-
-                      { don't generate invalid line info if no sources are available for the current module }
-                      if not(get_module(current_filepos.moduleindex).sources_avail) then
-                        current_tokenpos.column:=0;
-
                       current_filepos:=current_tokenpos;
                   end
                 else
@@ -2728,32 +2723,16 @@ In case not, the value returned can be arbitrary.
                     ST_LINE:
                       begin
                         current_tokenpos.line:=tokenreadlongint;
-
-                        { don't generate invalid line info if no sources are available for the current module }
-                        if not(get_module(current_filepos.moduleindex).sources_avail) then
-                          current_tokenpos.line:=0;
-
                         current_filepos:=current_tokenpos;
                       end;
                     ST_COLUMN:
                       begin
                         current_tokenpos.column:=tokenreadword;
-                        { don't generate invalid line info if no sources are available for the current module }
-                        if not(get_module(current_filepos.moduleindex).sources_avail) then
-                          current_tokenpos.column:=0;
-
                         current_filepos:=current_tokenpos;
                       end;
                     ST_FILEINDEX:
                       begin
                         current_tokenpos.fileindex:=tokenreadword;
-                        { don't generate invalid line info if no sources are available for the current module }
-                        if not(get_module(current_filepos.moduleindex).sources_avail) then
-                          begin
-                            current_tokenpos.column:=0;
-                            current_tokenpos.line:=0;
-                          end;
-
                         current_filepos:=current_tokenpos;
                       end;
                     else