]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libcpp: adjust _cpp_file accessors
authorJason Merrill <jason@redhat.com>
Sun, 7 Dec 2025 07:34:15 +0000 (15:34 +0800)
committerJason Merrill <jason@redhat.com>
Sun, 7 Dec 2025 07:34:15 +0000 (15:34 +0800)
Back in r78875 mrs added cpp_get_path/dir accessors for _cpp_file in order
to interface with the darwin framework system.  But now I notice that the
latter duplicates the better-named _cpp_get_file_dir, and I'm inclined to
rename the former to match.

Perhaps we should drop the initial underscore since these are no
longer internal interfaces; OTOH, _cpp_hashnode_value and
_cpp_backup_tokens still have the initial underscore in cpplib.h.

libcpp/ChangeLog:

* include/cpplib.h (cpp_get_path, cpp_get_dir): Remove.
(_cpp_get_file_path, _cpp_get_file_name, _cpp_get_file_stat)
(_cpp_get_file_dir): Move prototypes from...
* internal.h: ...here.
* files.cc (_cpp_get_file_path): Rename from...
(cpp_get_path): ...this.
(cpp_get_dir): Remove.

gcc/ChangeLog:

* config/darwin-c.cc (find_subframework_header): Use
_cpp_get_file_*.

gcc/config/darwin-c.cc
libcpp/files.cc
libcpp/include/cpplib.h
libcpp/internal.h

index 7257015cd08d1b07f0a059807d8b5461ff738b20..c3a1cd5656147141f99ea4edee177725bcf94cf2 100644 (file)
@@ -537,17 +537,18 @@ find_subframework_header (cpp_reader *pfile, const char *header, cpp_dir **dirp)
   const char *n;
 
   for (b = cpp_get_buffer (pfile);
-       b && cpp_get_file (b) && cpp_get_path (cpp_get_file (b));
+       b && cpp_get_file (b) && _cpp_get_file_path (cpp_get_file (b));
        b = cpp_get_prev (b))
     {
-      n = find_subframework_file (fname, cpp_get_path (cpp_get_file (b)));
+      n = find_subframework_file (fname,
+                                 _cpp_get_file_path (cpp_get_file (b)));
       if (n)
        {
          /* Logically, the place where we found the subframework is
             the place where we found the Framework that contains the
             subframework.  This is useful for tracking wether or not
             we are in a system header.  */
-         *dirp = cpp_get_dir (cpp_get_file (b));
+         *dirp = _cpp_get_file_dir (cpp_get_file (b));
          return n;
        }
     }
index d80c4bfd907755d9d9f630bfd5023614b6132ac4..f8b331294865449a833bbf6644e73a99fa796728 100644 (file)
@@ -2335,6 +2335,16 @@ _cpp_get_file_name (_cpp_file *file)
   return file->name;
 }
 
+/* Get the path associated with the _cpp_file F.  The path includes
+   the base name from the include directive and the directory it was
+   found in via the search path.  */
+
+const char *
+_cpp_get_file_path (_cpp_file *f)
+{
+  return f->path;
+}
+
 /* Inteface to file statistics record in _cpp_file structure. */
 struct stat *
 _cpp_get_file_stat (_cpp_file *file)
@@ -2574,24 +2584,6 @@ validate_pch (cpp_reader *pfile, _cpp_file *file, const char *pchname)
   return valid;
 }
 
-/* Get the path associated with the _cpp_file F.  The path includes
-   the base name from the include directive and the directory it was
-   found in via the search path.  */
-
-const char *
-cpp_get_path (struct _cpp_file *f)
-{
-  return f->path;
-}
-
-/* Get the directory associated with the _cpp_file F.  */
-
-cpp_dir *
-cpp_get_dir (struct _cpp_file *f)
-{
-  return f->dir;
-}
-
 /* Get the cpp_buffer currently associated with the cpp_reader
    PFILE.  */
 
index 5190ff7d08fecdc24a184b1e9da7741ecc4485ed..16f030c82f38c03322aadddeb2338e22dc6dc16d 100644 (file)
@@ -1563,8 +1563,10 @@ extern void cpp_make_system_header (cpp_reader *, int, int);
 extern bool cpp_push_include (cpp_reader *, const char *);
 extern bool cpp_push_default_include (cpp_reader *, const char *);
 extern void cpp_change_file (cpp_reader *, enum lc_reason, const char *);
-extern const char *cpp_get_path (struct _cpp_file *);
-extern cpp_dir *cpp_get_dir (struct _cpp_file *);
+extern const char *_cpp_get_file_path (_cpp_file *);
+extern const char *_cpp_get_file_name (_cpp_file *);
+extern struct stat *_cpp_get_file_stat (_cpp_file *);
+extern struct cpp_dir *_cpp_get_file_dir (_cpp_file *);
 extern cpp_buffer *cpp_get_buffer (cpp_reader *);
 extern struct _cpp_file *cpp_get_file (cpp_buffer *);
 extern cpp_buffer *cpp_get_prev (cpp_buffer *);
index bcf55593b0cb5c8a6ee7e1e4b5bfd38e3101659c..ae9852414156e59afab600a46dc66a1531f61411 100644 (file)
@@ -788,9 +788,6 @@ extern void _cpp_pop_file_buffer (cpp_reader *, struct _cpp_file *,
                                  const unsigned char *);
 extern bool _cpp_save_file_entries (cpp_reader *pfile, FILE *f);
 extern bool _cpp_read_file_entries (cpp_reader *, FILE *);
-extern const char *_cpp_get_file_name (_cpp_file *);
-extern struct stat *_cpp_get_file_stat (_cpp_file *);
-extern struct cpp_dir *_cpp_get_file_dir (_cpp_file *);
 extern bool _cpp_has_header (cpp_reader *, const char *, int,
                             enum include_type);