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