clang  6.0.0svn
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/SetVector.h"
16 #include "llvm/ADT/StringRef.h"
17 #include <cstdint>
18 #include <string>
19 #include <vector>
20 #include <map>
21 
22 namespace clang {
23 
24 namespace frontend {
25 
26 /// IncludeDirGroup - Identifies the group an include Entry belongs to,
27 /// representing its relative positive in the search list.
28 /// \#include directives whose paths are enclosed by string quotes ("")
29 /// start searching at the Quoted group (specified by '-iquote'),
30 /// then search the Angled group, then the System group, etc.
32  /// '\#include ""' paths, added by 'gcc -iquote'.
33  Quoted = 0,
34 
35  /// Paths for '\#include <>' added by '-I'.
37 
38  /// Like Angled, but marks header maps used when building frameworks.
40 
41  /// Like Angled, but marks system directories.
43 
44  /// Like System, but headers are implicitly wrapped in extern "C".
46 
47  /// Like System, but only used for C.
49 
50  /// Like System, but only used for C++.
52 
53  /// Like System, but only used for ObjC.
55 
56  /// Like System, but only used for ObjC++.
58 
59  /// Like System, but searched after the system directories.
61 };
62 
63 } // namespace frontend
64 
65 /// HeaderSearchOptions - Helper class for storing options related to the
66 /// initialization of the HeaderSearch object.
68 public:
69  struct Entry {
70  std::string Path;
72  unsigned IsFramework : 1;
73 
74  /// IgnoreSysRoot - This is false if an absolute path should be treated
75  /// relative to the sysroot, or true if it should always be the absolute
76  /// path.
77  unsigned IgnoreSysRoot : 1;
78 
79  Entry(StringRef path, frontend::IncludeDirGroup group, bool isFramework,
80  bool ignoreSysRoot)
81  : Path(path), Group(group), IsFramework(isFramework),
82  IgnoreSysRoot(ignoreSysRoot) {}
83  };
84 
86  /// A prefix to be matched against paths in \#include directives.
87  std::string Prefix;
88 
89  /// True if paths beginning with this prefix should be treated as system
90  /// headers.
92 
93  SystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader)
94  : Prefix(Prefix), IsSystemHeader(IsSystemHeader) {}
95  };
96 
97  /// If non-empty, the directory to use as a "virtual system root" for include
98  /// paths.
99  std::string Sysroot;
100 
101  /// User specified include entries.
102  std::vector<Entry> UserEntries;
103 
104  /// User-specified system header prefixes.
105  std::vector<SystemHeaderPrefix> SystemHeaderPrefixes;
106 
107  /// The directory which holds the compiler resource files (builtin includes,
108  /// etc.).
109  std::string ResourceDir;
110 
111  /// \brief The directory used for the module cache.
112  std::string ModuleCachePath;
113 
114  /// \brief The directory used for a user build.
115  std::string ModuleUserBuildPath;
116 
117  /// \brief The mapping of module names to prebuilt module files.
118  std::map<std::string, std::string> PrebuiltModuleFiles;
119 
120  /// \brief The directories used to load prebuilt module files.
121  std::vector<std::string> PrebuiltModulePaths;
122 
123  /// The module/pch container format.
124  std::string ModuleFormat;
125 
126  /// \brief Whether we should disable the use of the hash string within the
127  /// module cache.
128  ///
129  /// Note: Only used for testing!
130  unsigned DisableModuleHash : 1;
131 
132  /// \brief Implicit module maps. This option is enabld by default when
133  /// modules is enabled.
134  unsigned ImplicitModuleMaps : 1;
135 
136  /// \brief Set the 'home directory' of a module map file to the current
137  /// working directory (or the home directory of the module map file that
138  /// contained the 'extern module' directive importing this module map file
139  /// if any) rather than the directory containing the module map file.
140  //
141  /// The home directory is where we look for files named in the module map
142  /// file.
144 
145  /// \brief The interval (in seconds) between pruning operations.
146  ///
147  /// This operation is expensive, because it requires Clang to walk through
148  /// the directory structure of the module cache, stat()'ing and removing
149  /// files.
150  ///
151  /// The default value is large, e.g., the operation runs once a week.
152  unsigned ModuleCachePruneInterval = 7 * 24 * 60 * 60;
153 
154  /// \brief The time (in seconds) after which an unused module file will be
155  /// considered unused and will, therefore, be pruned.
156  ///
157  /// When the module cache is pruned, any module file that has not been
158  /// accessed in this many seconds will be removed. The default value is
159  /// large, e.g., a month, to avoid forcing infrequently-used modules to be
160  /// regenerated often.
161  unsigned ModuleCachePruneAfter = 31 * 24 * 60 * 60;
162 
163  /// \brief The time in seconds when the build session started.
164  ///
165  /// This time is used by other optimizations in header search and module
166  /// loading.
167  uint64_t BuildSessionTimestamp = 0;
168 
169  /// \brief The set of macro names that should be ignored for the purposes
170  /// of computing the module hash.
172 
173  /// \brief The set of user-provided virtual filesystem overlay files.
174  std::vector<std::string> VFSOverlayFiles;
175 
176  /// Include the compiler builtin includes.
177  unsigned UseBuiltinIncludes : 1;
178 
179  /// Include the system standard include search directories.
181 
182  /// Include the system standard C++ library include search directories.
184 
185  /// Use libc++ instead of the default libstdc++.
186  unsigned UseLibcxx : 1;
187 
188  /// Whether header search information should be output as for -v.
189  unsigned Verbose : 1;
190 
191  /// \brief If true, skip verifying input files used by modules if the
192  /// module was already verified during this build session (see
193  /// \c BuildSessionTimestamp).
195 
196  /// \brief Whether to validate system input files when a module is loaded.
198 
199  /// Whether the module includes debug information (-gmodules).
200  unsigned UseDebugInfo : 1;
201 
203 
204  unsigned ModulesHashContent : 1;
205 
206  HeaderSearchOptions(StringRef _Sysroot = "/")
207  : Sysroot(_Sysroot), ModuleFormat("raw"), DisableModuleHash(false),
208  ImplicitModuleMaps(false), ModuleMapFileHomeIsCwd(false),
209  UseBuiltinIncludes(true), UseStandardSystemIncludes(true),
210  UseStandardCXXIncludes(true), UseLibcxx(false), Verbose(false),
211  ModulesValidateOncePerBuildSession(false),
212  ModulesValidateSystemHeaders(false), UseDebugInfo(false),
213  ModulesValidateDiagnosticOptions(true), ModulesHashContent(false) {}
214 
215  /// AddPath - Add the \p Path path to the specified \p Group list.
216  void AddPath(StringRef Path, frontend::IncludeDirGroup Group,
217  bool IsFramework, bool IgnoreSysRoot) {
218  UserEntries.emplace_back(Path, Group, IsFramework, IgnoreSysRoot);
219  }
220 
221  /// AddSystemHeaderPrefix - Override whether \#include directives naming a
222  /// path starting with \p Prefix should be considered as naming a system
223  /// header.
224  void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) {
225  SystemHeaderPrefixes.emplace_back(Prefix, IsSystemHeader);
226  }
227 
228  void AddVFSOverlayFile(StringRef Name) {
229  VFSOverlayFiles.push_back(Name);
230  }
231 
232  void AddPrebuiltModulePath(StringRef Name) {
233  PrebuiltModulePaths.push_back(Name);
234  }
235 };
236 
237 } // namespace clang
238 
239 #endif // LLVM_CLANG_LEX_HEADERSEARCHOPTIONS_H
Paths for &#39;#include <>&#39; added by &#39;-I&#39;.
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...
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...
#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.
&#39;#include ""&#39; paths, added by &#39;gcc -iquote&#39;.
Like Angled, but marks system directories.
unsigned UseDebugInfo
Whether the module includes debug information (-gmodules).
Dataflow Directional Tag Classes.
Like System, but only used for C.
HeaderSearchOptions - Helper class for storing options related to the initialization of the HeaderSea...
unsigned ModuleMapFileHomeIsCwd
Set the &#39;home directory&#39; of a module map file to the current working directory (or the home directory...
Like Angled, but marks header maps used when building frameworks.
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.
std::map< std::string, std::string > PrebuiltModuleFiles
The mapping of module names to prebuilt module files.
Entry(StringRef path, frontend::IncludeDirGroup group, bool isFramework, bool ignoreSysRoot)
std::string ModuleFormat
The module/pch container format.