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