File indexing completed on 2026-05-10 08:36:56
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_CLANG_LEX_HEADERSEARCHOPTIONS_H
0010 #define LLVM_CLANG_LEX_HEADERSEARCHOPTIONS_H
0011
0012 #include "clang/Basic/LLVM.h"
0013 #include "llvm/ADT/CachedHashString.h"
0014 #include "llvm/ADT/SetVector.h"
0015 #include "llvm/ADT/StringRef.h"
0016 #include "llvm/Support/HashBuilder.h"
0017 #include <cstdint>
0018 #include <map>
0019 #include <string>
0020 #include <vector>
0021
0022 namespace clang {
0023
0024 namespace frontend {
0025
0026
0027
0028
0029
0030
0031 enum IncludeDirGroup {
0032
0033 Quoted = 0,
0034
0035
0036 Angled,
0037
0038
0039 System,
0040
0041
0042 ExternCSystem,
0043
0044
0045 CSystem,
0046
0047
0048 CXXSystem,
0049
0050
0051 ObjCSystem,
0052
0053
0054 ObjCXXSystem,
0055
0056
0057 After
0058 };
0059
0060 }
0061
0062
0063
0064 class HeaderSearchOptions {
0065 public:
0066 struct Entry {
0067 std::string Path;
0068 frontend::IncludeDirGroup Group;
0069 LLVM_PREFERRED_TYPE(bool)
0070 unsigned IsFramework : 1;
0071
0072
0073
0074
0075 LLVM_PREFERRED_TYPE(bool)
0076 unsigned IgnoreSysRoot : 1;
0077
0078 Entry(StringRef path, frontend::IncludeDirGroup group, bool isFramework,
0079 bool ignoreSysRoot)
0080 : Path(path), Group(group), IsFramework(isFramework),
0081 IgnoreSysRoot(ignoreSysRoot) {}
0082 };
0083
0084 struct SystemHeaderPrefix {
0085
0086 std::string Prefix;
0087
0088
0089
0090 bool IsSystemHeader;
0091
0092 SystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader)
0093 : Prefix(Prefix), IsSystemHeader(IsSystemHeader) {}
0094 };
0095
0096
0097
0098 std::string Sysroot;
0099
0100
0101 std::vector<Entry> UserEntries;
0102
0103
0104 std::vector<SystemHeaderPrefix> SystemHeaderPrefixes;
0105
0106
0107
0108 std::string ResourceDir;
0109
0110
0111 std::string ModuleCachePath;
0112
0113
0114 std::string ModuleUserBuildPath;
0115
0116
0117 std::map<std::string, std::string, std::less<>> PrebuiltModuleFiles;
0118
0119
0120 std::vector<std::string> PrebuiltModulePaths;
0121
0122
0123 std::string ModuleFormat;
0124
0125
0126
0127
0128
0129 LLVM_PREFERRED_TYPE(bool)
0130 unsigned DisableModuleHash : 1;
0131
0132
0133
0134 LLVM_PREFERRED_TYPE(bool)
0135 unsigned ImplicitModuleMaps : 1;
0136
0137
0138
0139
0140
0141
0142
0143
0144 LLVM_PREFERRED_TYPE(bool)
0145 unsigned ModuleMapFileHomeIsCwd : 1;
0146
0147
0148
0149
0150
0151 LLVM_PREFERRED_TYPE(bool)
0152 unsigned ModuleFileHomeIsCwd : 1;
0153
0154
0155
0156 LLVM_PREFERRED_TYPE(bool)
0157 unsigned EnablePrebuiltImplicitModules : 1;
0158
0159
0160
0161
0162
0163
0164
0165
0166 unsigned ModuleCachePruneInterval = 7 * 24 * 60 * 60;
0167
0168
0169
0170
0171
0172
0173
0174
0175 unsigned ModuleCachePruneAfter = 31 * 24 * 60 * 60;
0176
0177
0178
0179
0180
0181 uint64_t BuildSessionTimestamp = 0;
0182
0183
0184
0185 llvm::SmallSetVector<llvm::CachedHashString, 16> ModulesIgnoreMacros;
0186
0187
0188 std::vector<std::string> VFSOverlayFiles;
0189
0190
0191 LLVM_PREFERRED_TYPE(bool)
0192 unsigned UseBuiltinIncludes : 1;
0193
0194
0195 LLVM_PREFERRED_TYPE(bool)
0196 unsigned UseStandardSystemIncludes : 1;
0197
0198
0199 LLVM_PREFERRED_TYPE(bool)
0200 unsigned UseStandardCXXIncludes : 1;
0201
0202
0203 LLVM_PREFERRED_TYPE(bool)
0204 unsigned UseLibcxx : 1;
0205
0206
0207 LLVM_PREFERRED_TYPE(bool)
0208 unsigned Verbose : 1;
0209
0210
0211
0212
0213 LLVM_PREFERRED_TYPE(bool)
0214 unsigned ModulesValidateOncePerBuildSession : 1;
0215
0216
0217 LLVM_PREFERRED_TYPE(bool)
0218 unsigned ModulesValidateSystemHeaders : 1;
0219
0220
0221
0222 LLVM_PREFERRED_TYPE(bool)
0223 unsigned ValidateASTInputFilesContent : 1;
0224
0225
0226 LLVM_PREFERRED_TYPE(bool)
0227 unsigned ForceCheckCXX20ModulesInputFiles : 1;
0228
0229
0230 LLVM_PREFERRED_TYPE(bool)
0231 unsigned UseDebugInfo : 1;
0232
0233 LLVM_PREFERRED_TYPE(bool)
0234 unsigned ModulesValidateDiagnosticOptions : 1;
0235
0236
0237
0238 LLVM_PREFERRED_TYPE(bool)
0239 unsigned ModulesSkipDiagnosticOptions : 1;
0240
0241
0242
0243 LLVM_PREFERRED_TYPE(bool)
0244 unsigned ModulesSkipHeaderSearchPaths : 1;
0245
0246
0247
0248 LLVM_PREFERRED_TYPE(bool)
0249 unsigned ModulesSkipPragmaDiagnosticMappings : 1;
0250
0251
0252 LLVM_PREFERRED_TYPE(bool)
0253 unsigned ModulesPruneNonAffectingModuleMaps : 1;
0254
0255 LLVM_PREFERRED_TYPE(bool)
0256 unsigned ModulesHashContent : 1;
0257
0258
0259 LLVM_PREFERRED_TYPE(bool)
0260 unsigned ModulesSerializeOnlyPreprocessor : 1;
0261
0262
0263
0264
0265
0266
0267 LLVM_PREFERRED_TYPE(bool)
0268 unsigned ModulesStrictContextHash : 1;
0269
0270
0271 LLVM_PREFERRED_TYPE(bool)
0272 unsigned ModulesIncludeVFSUsage : 1;
0273
0274
0275
0276
0277 LLVM_PREFERRED_TYPE(bool)
0278 unsigned AllowModuleMapSubdirectorySearch : 1;
0279
0280 HeaderSearchOptions(StringRef _Sysroot = "/")
0281 : Sysroot(_Sysroot), ModuleFormat("raw"), DisableModuleHash(false),
0282 ImplicitModuleMaps(false), ModuleMapFileHomeIsCwd(false),
0283 ModuleFileHomeIsCwd(false), EnablePrebuiltImplicitModules(false),
0284 UseBuiltinIncludes(true), UseStandardSystemIncludes(true),
0285 UseStandardCXXIncludes(true), UseLibcxx(false), Verbose(false),
0286 ModulesValidateOncePerBuildSession(false),
0287 ModulesValidateSystemHeaders(false),
0288 ValidateASTInputFilesContent(false),
0289 ForceCheckCXX20ModulesInputFiles(false), UseDebugInfo(false),
0290 ModulesValidateDiagnosticOptions(true),
0291 ModulesSkipDiagnosticOptions(false),
0292 ModulesSkipHeaderSearchPaths(false),
0293 ModulesSkipPragmaDiagnosticMappings(false),
0294 ModulesPruneNonAffectingModuleMaps(true), ModulesHashContent(false),
0295 ModulesSerializeOnlyPreprocessor(false),
0296 ModulesStrictContextHash(false), ModulesIncludeVFSUsage(false),
0297 AllowModuleMapSubdirectorySearch(true) {}
0298
0299
0300 void AddPath(StringRef Path, frontend::IncludeDirGroup Group,
0301 bool IsFramework, bool IgnoreSysRoot) {
0302 UserEntries.emplace_back(Path, Group, IsFramework, IgnoreSysRoot);
0303 }
0304
0305
0306
0307
0308 void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) {
0309 SystemHeaderPrefixes.emplace_back(Prefix, IsSystemHeader);
0310 }
0311
0312 void AddVFSOverlayFile(StringRef Name) {
0313 VFSOverlayFiles.push_back(std::string(Name));
0314 }
0315
0316 void AddPrebuiltModulePath(StringRef Name) {
0317 PrebuiltModulePaths.push_back(std::string(Name));
0318 }
0319 };
0320
0321 template <typename HasherT, llvm::endianness Endianness>
0322 inline void addHash(llvm::HashBuilder<HasherT, Endianness> &HBuilder,
0323 const HeaderSearchOptions::Entry &E) {
0324 HBuilder.add(E.Path, E.Group, E.IsFramework, E.IgnoreSysRoot);
0325 }
0326
0327 template <typename HasherT, llvm::endianness Endianness>
0328 inline void addHash(llvm::HashBuilder<HasherT, Endianness> &HBuilder,
0329 const HeaderSearchOptions::SystemHeaderPrefix &SHP) {
0330 HBuilder.add(SHP.Prefix, SHP.IsSystemHeader);
0331 }
0332
0333 }
0334
0335 #endif