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

Macros

#define INO_T_EQ(A, B)   ((A) == (B))
#define INO_T_COPY(DEST, SRC)   (DEST) = (SRC)
#define DIRS_EQ(A, B)
#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 *, int)
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)
static void free_path ()
static void add_env_var_paths ()
static void add_sysroot_to_chain ()
static void merge_include_chains ()
void split_quote_chain ()
void add_cpp_dir_path ()
void add_path ()
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 ()
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 [4]
static struct cpp_dir * tails [4]
static bool quote_ignores_source_dir
struct target_c_incpath_s target_c_incpath = { TARGET_EXTRA_PRE_INCLUDES, TARGET_EXTRA_INCLUDES }

Macro Definition Documentation

#define DIRS_EQ (   A,
 
)
Value:
((A)->dev == (B)->dev \
&& INO_T_EQ ((A)->ino, (B)->ino))
#define INO_T_COPY (   DEST,
  SRC 
)    (DEST) = (SRC)
#define INO_T_EQ (   A,
 
)    ((A) == (B))

Set up combined include path chain for the preprocessor. Copyright (C) 1986-2013 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.

#define TARGET_EXTRA_INCLUDES   hook_void_charptr_charptr_int
#define TARGET_EXTRA_PRE_INCLUDES   hook_void_charptr_charptr_int

Enumeration Type Documentation

anonymous enum
Enumerator:
REASON_QUIET 
REASON_NOENT 
REASON_DUP 
REASON_DUP_SYS 

Function Documentation

void add_cpp_dir_path ( )

Add P to the chain specified by CHAIN.

static void add_env_var_paths ( const char *  ,
int   
)
static
static void add_env_var_paths ( )
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(), PATH_SEPARATOR, and SYSTEM.

void add_path ( )

Add PATH to the include chain CHAIN. PATH must be malloc-ed and NUL-terminated.

Referenced by add_env_var_paths(), and add_standard_paths().

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

Append the standard include chain defined in cppdefault.c.

     Look for directories that start with the standard prefix.
     "Translate" them, i.e. replace /usr/local/lib/gcc... with
     IPREFIX and search them first.   
             Should we be translating sysrooted dirs too?  Assume
             that iprefix and sysroot are mutually exclusive, for
             now.   
         Should this directory start with the sysroot?   
             If this path starts with the configure-time prefix,
             but the compiler has been relocated, replace it
             with the run-time prefix.  The run-time exec prefix
             is GCC_EXEC_PREFIX.  Compute the path from there back
             to the toplevel prefix.   
                 Make relative prefix expects the first argument
                 to be a program, not a directory.   

References add_path(), default_include::add_sysroot, default_include::cplusplus, cpp_GCC_INCLUDE_DIR, cpp_include_defaults, default_include::cxx_aware, dir_separator_str, default_include::fname, default_include::multilib, NULL, and SYSTEM.

static void add_sysroot_to_chain ( const char *  ,
int   
)
static

Referenced by add_sysroot_to_chain().

static void add_sysroot_to_chain ( )
static

Add SYSROOT to any user-supplied paths in CHAIN starting with "=".

References add_sysroot_to_chain(), AFTER, BRACKET, heads, QUOTE, remove_duplicates(), SYSTEM, and tails.

static void free_path ( struct cpp_dir *  ,
int   
)
static
static void free_path ( )
static

Free an element of the include chain, possibly giving a reason.

struct cpp_dir* get_added_cpp_dirs ( )
read

Return the current chain of cpp dirs.

static void hook_void_charptr_charptr_int ( const char *  sysroot,
const char *  iprefix,
int  stdinc 
)
static
static void merge_include_chains ( const char *  ,
cpp_reader *  ,
int   
)
static
static void merge_include_chains ( )
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.

 Add the sysroot to user-supplied paths starting with "=".   
 Join the SYSTEM and AFTER chains.  Remove duplicates in the
 resulting SYSTEM chain.   
 Remove duplicates from BRACKET that are in itself or SYSTEM, and
 join it to SYSTEM.   
 Remove duplicates from QUOTE that are in itself or SYSTEM, and
 join it to BRACKET.   
 If verbose, print the list of dirs to search.   
void register_include_chains ( cpp_reader *  pfile,
const char *  sysroot,
const char *  iprefix,
const char *  imultilib,
int  stdinc,
int  cxx_stdinc,
int  verbose 
)

Exported function to handle include chain merging, duplicate removal, and registration with cpplib.

CPATH and language-dependent environment variables may add to the include chain.

 Finally chain on the standard directories.   

References heads.

static struct cpp_dir * remove_duplicates ( cpp_reader *  pfile,
struct cpp_dir *  head,
struct cpp_dir *  system,
struct cpp_dir *  join,
int  verbose 
)
staticread

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.

         Dirs that don't exist are silently ignored, unless verbose.   
             If -Wmissing-include-dirs is given, warn.   
         Remove this one if it is in the system chain.   
             Duplicate of something earlier in the same chain?   
                 Last in the chain and duplicate of JOIN?   
                 Unique, so keep this directory.   
     Remove this entry from the chain.   

References cpp_options, errno, and REASON_NOENT.

Referenced by add_sysroot_to_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.)

This is NOT redundant.


Variable Documentation

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

Referenced by add_standard_paths().

struct cpp_dir* heads[4]
static

Include chains heads and tails.

Referenced by add_sysroot_to_chain(), and register_include_chains().

bool quote_ignores_source_dir
static
struct cpp_dir* tails[4]
static

Referenced by add_sysroot_to_chain().