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