]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/Lex/HeaderSearchOptions.h
Merge clang trunk r300422 and resolve conflicts.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / Lex / HeaderSearchOptions.h
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.
29   enum IncludeDirGroup {
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.
47 class HeaderSearchOptions {
48 public:
49   struct Entry {
50     std::string Path;
51     frontend::IncludeDirGroup Group;
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
65   struct SystemHeaderPrefix {
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.
71     bool IsSystemHeader;
72
73     SystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader)
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.
120   unsigned ModuleMapFileHomeIsCwd : 1;
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.
129   unsigned ModuleCachePruneInterval;
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.
138   unsigned ModuleCachePruneAfter;
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.
144   uint64_t BuildSessionTimestamp;
145
146   /// \brief The set of macro names that should be ignored for the purposes
147   /// of computing the module hash.
148   llvm::SmallSetVector<llvm::CachedHashString, 16> ModulesIgnoreMacros;
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.
157   unsigned UseStandardSystemIncludes : 1;
158
159   /// Include the system standard C++ library include search directories.
160   unsigned UseStandardCXXIncludes : 1;
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).
171   unsigned ModulesValidateOncePerBuildSession : 1;
172
173   /// \brief Whether to validate system input files when a module is loaded.
174   unsigned ModulesValidateSystemHeaders : 1;
175
176   /// Whether the module includes debug information (-gmodules).
177   unsigned UseDebugInfo : 1;
178
179   unsigned ModulesValidateDiagnosticOptions : 1;
180
181   unsigned ModulesHashContent : 1;
182
183   HeaderSearchOptions(StringRef _Sysroot = "/")
184       : Sysroot(_Sysroot), ModuleFormat("raw"), DisableModuleHash(0),
185         ImplicitModuleMaps(0), ModuleMapFileHomeIsCwd(0),
186         ModuleCachePruneInterval(7 * 24 * 60 * 60),
187         ModuleCachePruneAfter(31 * 24 * 60 * 60), BuildSessionTimestamp(0),
188         UseBuiltinIncludes(true), UseStandardSystemIncludes(true),
189         UseStandardCXXIncludes(true), UseLibcxx(false), Verbose(false),
190         ModulesValidateOncePerBuildSession(false),
191         ModulesValidateSystemHeaders(false), UseDebugInfo(false),
192         ModulesValidateDiagnosticOptions(true), ModulesHashContent(false) {}
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