GCC Middle and Back End API Reference
incpath.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "target.h"
#include "cpplib.h"
#include "prefix.h"
#include "intl.h"
#include "incpath.h"
#include "cppdefault.h"
Include dependency graph for incpath.cc:

Macros

#define INO_T_EQ(A, B)
 
#define INO_T_COPY(DEST, SRC)
 
#define DIRS_EQ(A, B)
 
#define HOST_STAT_FOR_64BIT_INODES   stat
 
#define TARGET_EXTRA_INCLUDES   hook_void_charptr_charptr_int
 
#define TARGET_EXTRA_PRE_INCLUDES   hook_void_charptr_charptr_int
 

Enumerations

enum  { REASON_QUIET = 0 , REASON_NOENT , REASON_DUP , REASON_DUP_SYS }
 

Functions

static void add_env_var_paths (const char *, incpath_kind)
 
static void add_standard_paths (const char *, const char *, const char *, int)
 
static void free_path (struct cpp_dir *, int)
 
static void merge_include_chains (const char *, cpp_reader *, int)
 
static void add_sysroot_to_chain (const char *, int)
 
static struct cpp_dir * remove_duplicates (cpp_reader *, struct cpp_dir *, struct cpp_dir *, struct cpp_dir *, int)
 
void split_quote_chain (void)
 
void add_cpp_dir_path (cpp_dir *p, incpath_kind chain)
 
void add_path (char *path, incpath_kind chain, int cxx_aware, bool user_supplied_p)
 
void register_include_chains (cpp_reader *pfile, const char *sysroot, const char *iprefix, const char *imultilib, int stdinc, int cxx_stdinc, int verbose)
 
struct cpp_dir * get_added_cpp_dirs (incpath_kind chain)
 
static void hook_void_charptr_charptr_int (const char *sysroot, const char *iprefix, int stdinc)
 

Variables

static const char dir_separator_str [] = { DIR_SEPARATOR, 0 }
 
static struct cpp_dir * heads [INC_MAX]
 
static struct cpp_dir * tails [INC_MAX]
 
static bool quote_ignores_source_dir
 
struct target_c_incpath_s target_c_incpath = { TARGET_EXTRA_PRE_INCLUDES, TARGET_EXTRA_INCLUDES }
 

Macro Definition Documentation

◆ DIRS_EQ

#define DIRS_EQ ( A,
B )
Value:
((A)->dev == (B)->dev \
&& INO_T_EQ ((A)->ino, (B)->ino))
#define INO_T_EQ(A, B)
Definition incpath.cc:36

Referenced by remove_duplicates().

◆ HOST_STAT_FOR_64BIT_INODES

#define HOST_STAT_FOR_64BIT_INODES   stat

Referenced by remove_duplicates().

◆ INO_T_COPY

#define INO_T_COPY ( DEST,
SRC )
Value:
(DEST) = (SRC)

Referenced by remove_duplicates().

◆ INO_T_EQ

#define INO_T_EQ ( A,
B )
Value:
((A) == (B))
Set up combined include path chain for the preprocessor.
Copyright (C) 1986-2024 Free Software Foundation, Inc.

Broken out of cppinit.c and cppfiles.c and rewritten Mar 2003.

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3, or (at your option) any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
Microsoft Windows does not natively support inodes.
VMS has non-numeric inodes.   

◆ TARGET_EXTRA_INCLUDES

#define TARGET_EXTRA_INCLUDES   hook_void_charptr_charptr_int

◆ TARGET_EXTRA_PRE_INCLUDES

#define TARGET_EXTRA_PRE_INCLUDES   hook_void_charptr_charptr_int

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
REASON_QUIET 
REASON_NOENT 
REASON_DUP 
REASON_DUP_SYS 

Function Documentation

◆ add_cpp_dir_path()

void add_cpp_dir_path ( cpp_dir * p,
incpath_kind chain )
Add P to the chain specified by CHAIN.   

References heads, and tails.

Referenced by add_path().

◆ add_env_var_paths()

static void add_env_var_paths ( const char * env_var,
incpath_kind chain )
static
Read ENV_VAR for a PATH_SEPARATOR-separated list of file names; and
append all the names to the search path CHAIN.   

References add_path(), INC_SYSTEM, path, and PATH_SEPARATOR.

Referenced by register_include_chains().

◆ add_path()

void add_path ( char * path,
incpath_kind chain,
int cxx_aware,
bool user_supplied_p )
Add PATH to the include chain CHAIN. PATH must be malloc-ed and
NUL-terminated.   

References add_cpp_dir_path(), end(), INC_AFTER, INC_SYSTEM, NULL, and path.

Referenced by add_env_var_paths(), and add_standard_paths().

◆ add_standard_paths()

static void add_standard_paths ( const char * sysroot,
const char * iprefix,
const char * imultilib,
int cxx_stdinc )
static

◆ add_sysroot_to_chain()

static void add_sysroot_to_chain ( const char * sysroot,
int chain )
static
Add SYSROOT to any user-supplied paths in CHAIN starting with
"=" or "$SYSROOT".   

References heads, NULL, and startswith().

Referenced by merge_include_chains().

◆ free_path()

static void free_path ( struct cpp_dir * path,
int reason )
static
Free an element of the include chain, possibly giving a reason.   

References _, free(), REASON_DUP, REASON_DUP_SYS, REASON_NOENT, and REASON_QUIET.

Referenced by remove_duplicates(), and split_quote_chain().

◆ get_added_cpp_dirs()

struct cpp_dir * get_added_cpp_dirs ( incpath_kind chain)
Return the current chain of cpp dirs.   

References heads.

◆ hook_void_charptr_charptr_int()

static void hook_void_charptr_charptr_int ( const char * sysroot,
const char * iprefix,
int stdinc )
static

◆ merge_include_chains()

static void merge_include_chains ( const char * sysroot,
cpp_reader * pfile,
int verbose )
static
Merge the four include chains together in the order quote, bracket,
system, after.  Remove duplicate dirs (determined in
system-specific manner).

We can't just merge the lists and then uniquify them because then
we may lose directories from the <> search path that should be
there; consider -iquote foo -iquote bar -Ifoo -Iquux.  It is
however safe to treat -iquote bar -iquote foo -Ifoo -Iquux as if
written -iquote bar -Ifoo -Iquux.   

References _, add_sysroot_to_chain(), heads, INC_AFTER, INC_BRACKET, INC_EMBED, INC_QUOTE, INC_SYSTEM, remove_duplicates(), tails, and verbose.

Referenced by register_include_chains().

◆ register_include_chains()

void register_include_chains ( cpp_reader * pfile,
const char * sysroot,
const char * iprefix,
const char * imultilib,
int stdinc,
int cxx_stdinc,
int verbose )

◆ remove_duplicates()

static struct cpp_dir * remove_duplicates ( cpp_reader * pfile,
struct cpp_dir * head,
struct cpp_dir * system,
struct cpp_dir * join,
int verbose )
static
For each duplicate path in chain HEAD, keep just the first one.
Remove each path in chain HEAD that also exists in chain SYSTEM.
Set the NEXT pointer of the last path in the resulting chain to
JOIN, unless it duplicates JOIN in which case the last path is
removed.  Return the head of the resulting chain.  Any of HEAD,
JOIN and SYSTEM can be NULL.   

References cpp_options, DIRS_EQ, errno, free_path(), HOST_STAT_FOR_64BIT_INODES, INO_T_COPY, NULL, REASON_DUP, REASON_DUP_SYS, REASON_NOENT, REASON_QUIET, S_ISDIR, and verbose.

Referenced by merge_include_chains().

◆ split_quote_chain()

void split_quote_chain ( void )
Use given -I paths for #include "..." but not #include <...>, and
don't search the directory of the present file for #include "...".
(Note that -I. -I- is not the same as the default setup; -I. uses
the compiler's working dir.)   

References free_path(), heads, INC_BRACKET, INC_QUOTE, NULL, quote_ignores_source_dir, REASON_QUIET, and tails.

Variable Documentation

◆ dir_separator_str

const char dir_separator_str[] = { DIR_SEPARATOR, 0 }
static

Referenced by add_standard_paths().

◆ heads

struct cpp_dir* heads[INC_MAX]
static

◆ quote_ignores_source_dir

bool quote_ignores_source_dir
static

◆ tails

struct cpp_dir* tails[INC_MAX]
static

◆ target_c_incpath