unsigned int mod_time,
                            unsigned int length)
 {
+  file_name_index index
+    = version >= 5 ? file_names_size (): file_names_size () + 1;
+
   if (dwarf_line_debug >= 2)
-    {
-      size_t new_size;
-      if (version >= 5)
-       new_size = file_names_size ();
-      else
-       new_size = file_names_size () + 1;
-      gdb_printf (gdb_stdlog, "Adding file %zu: %s\n",
-                 new_size, name);
-    }
-  m_file_names.emplace_back (name, d_index, mod_time, length);
+    gdb_printf (gdb_stdlog, "Adding file %d: %s\n", index, name);
+
+  m_file_names.emplace_back (name, index, d_index, mod_time, length);
 }
 
 std::string
-line_header::file_file_name (int file) const
+line_header::file_file_name (const file_entry &fe) const
 {
-  /* Is the file number a valid index into the line header's file name
-     table?  Remember that file numbers start with one, not zero.  */
-  if (is_valid_file_index (file))
-    {
-      const file_entry *fe = file_name_at (file);
+  gdb_assert (is_valid_file_index (fe.index));
 
-      if (!IS_ABSOLUTE_PATH (fe->name))
-       {
-         const char *dir = fe->include_dir (this);
-         if (dir != NULL)
-           return path_join (dir, fe->name);
-       }
+  if (IS_ABSOLUTE_PATH (fe.name))
+    return fe.name;
 
-      return fe->name;
-    }
-  else
-    {
-      /* The compiler produced a bogus file number.  We can at least
-        record the macro definitions made in the file, even if we
-        won't be able to find the file by name.  */
-      complaint (_("bad file number in macro information (%d)"),
-                file);
+  const char *dir = fe.include_dir (this);
+  if (dir == nullptr)
+    return fe.name;
 
-      return string_printf ("<bad macro file number %d>", file);
-    }
+  return path_join (dir, fe.name);
 }
 
 static void
 
 {
   file_entry () = default;
 
-  file_entry (const char *name_, dir_index d_index_,
+  file_entry (const char *name_, file_name_index index_, dir_index d_index_,
              unsigned int mod_time_, unsigned int length_)
     : name (name_),
+      index (index_),
       d_index (d_index_),
       mod_time (mod_time_),
       length (length_)
      owned by debug_line_buffer.  */
   const char *name {};
 
+  /* The index of this file in the file table.  */
+  file_name_index index {};
+
   /* The directory index (1-based).  */
   dir_index d_index {};
 
   const gdb_byte *statement_program_start {}, *statement_program_end {};
 
   /* Return file name relative to the compilation directory of file
-     number FILE in this object's file name table.  */
-  std::string file_file_name (int file) const;
+     FE in this object's file name table.  */
+  std::string file_file_name (const file_entry &fe) const;
 
   /* Return the compilation directory of the compilation unit in the context of
      which this line header is read.  Return nullptr if non applicable.  */
 
                  const struct line_header *lh)
 {
   /* File name relative to the compilation directory of this source file.  */
-  std::string file_name = lh->file_file_name (file);
+  const file_entry *fe = lh->file_name_at (file);
+  std::string file_name;
+
+  if (fe != nullptr)
+    file_name = lh->file_file_name (*fe);
+  else
+    {
+      /* The compiler produced a bogus file number.  We can at least
+        record the macro definitions made in the file, even if we
+        won't be able to find the file by name.  */
+      complaint (_("bad file number in macro information (%d)"),
+                file);
+
+      file_name = string_printf ("<bad macro file number %d>", file);
+    }
 
   if (! current_file)
     {