clang  5.0.0
HeaderSearchOptions.h
Go to the documentation of this file.
1 //===--- HeaderSearchOptions.h ----------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_CLANG_LEX_HEADERSEARCHOPTIONS_H
11 #define LLVM_CLANG_LEX_HEADERSEARCHOPTIONS_H
12 
13 #include "clang/Basic/LLVM.h"
14 #include "llvm/ADT/CachedHashString.h"
15 #include "llvm/ADT/IntrusiveRefCntPtr.h"
16 #include "llvm/ADT/SetVector.h"
17 #include "llvm/ADT/StringRef.h"
18 #include <string>
19 #include <vector>
20 
21 namespace clang {
22 
23 namespace frontend {
24  /// IncludeDirGroup - Identifies the group an include Entry belongs to,
25  /// representing its relative positive in the search list.
26  /// \#include directives whose paths are enclosed by string quotes ("")
27  /// start searching at the Quoted group (specified by '-iquote'),
28  /// then search the Angled group, then the System group, etc.
30  Quoted = 0, ///< '\#include ""' paths, added by 'gcc -iquote'.
31  Angled, ///< Paths for '\#include <>' added by '-I'.
32  IndexHeaderMap, ///< Like Angled, but marks header maps used when
33  /// building frameworks.
34  System, ///< Like Angled, but marks system directories.
35  ExternCSystem, ///< Like System, but headers are implicitly wrapped in
36  /// extern "C".
37  CSystem, ///< Like System, but only used for C.
38  CXXSystem, ///< Like System, but only used for C++.
39  ObjCSystem, ///< Like System, but only used for ObjC.
40  ObjCXXSystem, ///< Like System, but only used for ObjC++.
41  After ///< Like System, but searched after the system directories.
42  };
43 }
44 
45 /// HeaderSearchOptions - Helper class for storing options related to the
46 /// initialization of the HeaderSearch object.
48 public:
49  struct Entry {
50  std::string Path;
52  unsigned IsFramework : 1;
53 
54  /// IgnoreSysRoot - This is false if an absolute path should be treated
55  /// relative to the sysroot, or true if it should always be the absolute
56  /// path.
57  unsigned IgnoreSysRoot : 1;
58 
59  Entry(StringRef path, frontend::IncludeDirGroup group, bool isFramework,
60  bool ignoreSysRoot)
61  : Path(path), Group(group), IsFramework(isFramework),
62  IgnoreSysRoot(ignoreSysRoot) {}
63  };
64 
66  /// A prefix to be matched against paths in \#include directives.
67  std::string Prefix;
68 
69  /// True if paths beginning with this prefix should be treated as system
70  /// headers.
72 
74  : Prefix(Prefix), IsSystemHeader(IsSystemHeader) {}
75  };
76 
77  /// If non-empty, the directory to use as a "virtual system root" for include
78  /// paths.
79  std::string Sysroot;
80 
81  /// User specified include entries.
82  std::vector<Entry> UserEntries;
83 
84  /// User-specified system header prefixes.
85  std::vector<SystemHeaderPrefix> SystemHeaderPrefixes;
86 
87  /// The directory which holds the compiler resource files (builtin includes,
88  /// etc.).
89  std::string ResourceDir;
90 
91  /// \brief The directory used for the module cache.
92  std::string ModuleCachePath;
93 
94  /// \brief The directory used for a user build.
95  std::string ModuleUserBuildPath;
96 
97  /// \brief The directories used to load prebuilt module files.
98  std::vector<std::string> PrebuiltModulePaths;
99 
100  /// The module/pch container format.
101  std::string ModuleFormat;
102 
103  /// \brief Whether we should disable the use of the hash string within the
104  /// module cache.
105  ///
106  /// Note: Only used for testing!
107  unsigned DisableModuleHash : 1;
108 
109  /// \brief Implicit module maps. This option is enabld by default when
110  /// modules is enabled.
111  unsigned ImplicitModuleMaps : 1;
112 
113  /// \brief Set the 'home directory' of a module map file to the current
114  /// working directory (or the home directory of the module map file that
115  /// contained the 'extern module' directive importing this module map file
116  /// if any) rather than the directory containing the module map file.
117  //
118  /// The home directory is where we look for files named in the module map
119  /// file.
121 
122  /// \brief The interval (in seconds) between pruning operations.
123  ///
124  /// This operation is expensive, because it requires Clang to walk through
125  /// the directory structure of the module cache, stat()'ing and removing
126  /// files.
127  ///
128  /// The default value is large, e.g., the operation runs once a week.
130 
131  /// \brief The time (in seconds) after which an unused module file will be
132  /// considered unused and will, therefore, be pruned.
133  ///
134  /// When the module cache is pruned, any module file that has not been
135  /// accessed in this many seconds will be removed. The default value is
136  /// large, e.g., a month, to avoid forcing infrequently-used modules to be
137  /// regenerated often.
139 
140  /// \brief The time in seconds when the build session started.
141  ///
142  /// This time is used by other optimizations in header search and module
143  /// loading.
145 
146  /// \brief The set of macro names that should be ignored for the purposes
147  /// of computing the module hash.
149 
150  /// \brief The set of user-provided virtual filesystem overlay files.
151  std::vector<std::string> VFSOverlayFiles;
152 
153  /// Include the compiler builtin includes.
154  unsigned UseBuiltinIncludes : 1;
155 
156  /// Include the system standard include search directories.
158 
159  /// Include the system standard C++ library include search directories.
161 
162  /// Use libc++ instead of the default libstdc++.
163  unsigned UseLibcxx : 1;
164 
165  /// Whether header search information should be output as for -v.
166  unsigned Verbose : 1;
167 
168  /// \brief If true, skip verifying input files used by modules if the
169  /// module was already verified during this build session (see
170  /// \c BuildSessionTimestamp).
172 
173  /// \brief Whether to validate system input files when a module is loaded.
175 
176  /// Whether the module includes debug information (-gmodules).
177  unsigned UseDebugInfo : 1;
178 
180 
181  unsigned ModulesHashContent : 1;
182 
183  HeaderSearchOptions(StringRef _Sysroot = "/")
184  : Sysroot(_Sysroot), ModuleFormat("raw"), DisableModuleHash(0),
186  ModuleCachePruneInterval(7 * 24 * 60 * 60),
187  ModuleCachePruneAfter(31 * 24 * 60 * 60), BuildSessionTimestamp(0),
193 
194  /// AddPath - Add the \p Path path to the specified \p Group list.
195  void AddPath(StringRef Path, frontend::IncludeDirGroup Group,
196  bool IsFramework, bool IgnoreSysRoot) {
197  UserEntries.emplace_back(Path, Group, IsFramework, IgnoreSysRoot);
198  }
199 
200  /// AddSystemHeaderPrefix - Override whether \#include directives naming a
201  /// path starting with \p Prefix should be considered as naming a system
202  /// header.
203  void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) {
204  SystemHeaderPrefixes.emplace_back(Prefix, IsSystemHeader);
205  }
206 
207  void AddVFSOverlayFile(StringRef Name) {
208  VFSOverlayFiles.push_back(Name);
209  }
210 
211  void AddPrebuiltModulePath(StringRef Name) {
212  PrebuiltModulePaths.push_back(Name);
213  }
214 };
215 
216 } // end namespace clang
217 
218 #endif
Paths for '#include <>' added by '-I'.
std::vector< std::string > PrebuiltModulePaths
The directories used to load prebuilt module files.
unsigned UseLibcxx
Use libc++ instead of the default libstdc++.
unsigned ImplicitModuleMaps
Implicit module maps.
std::string ModuleUserBuildPath
The directory used for a user build.
Like System, but headers are implicitly wrapped in extern "C".
Like System, but only used for C++.
Like System, but only used for ObjC++.
llvm::SmallSetVector< llvm::CachedHashString, 16 > ModulesIgnoreMacros
The set of macro names that should be ignored for the purposes of computing the module hash...
void AddPath(StringRef Path, frontend::IncludeDirGroup Group, bool IsFramework, bool IgnoreSysRoot)
AddPath - Add the Path path to the specified Group list.
Like System, but searched after the system directories.
std::string ModuleCachePath
The directory used for the module cache.
bool IsSystemHeader
True if paths beginning with this prefix should be treated as system headers.
void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader)
AddSystemHeaderPrefix - Override whether #include directives naming a path starting with Prefix shoul...
std::vector< Entry > UserEntries
User specified include entries.
std::vector< SystemHeaderPrefix > SystemHeaderPrefixes
User-specified system header prefixes.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
std::vector< std::string > VFSOverlayFiles
The set of user-provided virtual filesystem overlay files.
std::string ResourceDir
The directory which holds the compiler resource files (builtin includes, etc.).
unsigned DisableModuleHash
Whether we should disable the use of the hash string within the module cache.
void AddVFSOverlayFile(StringRef Name)
unsigned IgnoreSysRoot
IgnoreSysRoot - This is false if an absolute path should be treated relative to the sysroot...
unsigned ModuleCachePruneInterval
The interval (in seconds) between pruning operations.
IncludeDirGroup
IncludeDirGroup - Identifies the group an include Entry belongs to, representing its relative positiv...
void AddPrebuiltModulePath(StringRef Name)
unsigned UseBuiltinIncludes
Include the compiler builtin includes.
unsigned ModulesValidateOncePerBuildSession
If true, skip verifying input files used by modules if the module was already verified during this bu...
uint64_t BuildSessionTimestamp
The time in seconds when the build session started.
#define false
Definition: stdbool.h:33
unsigned UseStandardSystemIncludes
Include the system standard include search directories.
SystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader)
unsigned ModulesValidateSystemHeaders
Whether to validate system input files when a module is loaded.
HeaderSearchOptions(StringRef _Sysroot="/")
unsigned Verbose
Whether header search information should be output as for -v.
frontend::IncludeDirGroup Group
Like System, but only used for ObjC.
std::string Prefix
A prefix to be matched against paths in #include directives.
'#include ""' paths, added by 'gcc -iquote'.
building frameworks.
unsigned UseDebugInfo
Whether the module includes debug information (-gmodules).
StringRef Name
Definition: USRFinder.cpp:123
Like System, but only used for C.
unsigned ModuleCachePruneAfter
The time (in seconds) after which an unused module file will be considered unused and will...
HeaderSearchOptions - Helper class for storing options related to the initialization of the HeaderSea...
unsigned ModuleMapFileHomeIsCwd
Set the 'home directory' of a module map file to the current working directory (or the home directory...
Like Angled, but marks header maps used when.
std::string Sysroot
If non-empty, the directory to use as a "virtual system root" for include paths.
#define true
Definition: stdbool.h:32
unsigned UseStandardCXXIncludes
Include the system standard C++ library include search directories.
Entry(StringRef path, frontend::IncludeDirGroup group, bool isFramework, bool ignoreSysRoot)
std::string ModuleFormat
The module/pch container format.