clang 23.0.0git
HeaderSearch.h
Go to the documentation of this file.
1//===- HeaderSearch.h - Resolve Header File Locations -----------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the HeaderSearch interface.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_LEX_HEADERSEARCH_H
14#define LLVM_CLANG_LEX_HEADERSEARCH_H
15
20#include "clang/Lex/HeaderMap.h"
21#include "clang/Lex/ModuleMap.h"
22#include "llvm/ADT/ArrayRef.h"
23#include "llvm/ADT/DenseMap.h"
24#include "llvm/ADT/SmallString.h"
25#include "llvm/ADT/StringMap.h"
26#include "llvm/ADT/StringRef.h"
27#include "llvm/ADT/StringSet.h"
28#include "llvm/Support/Allocator.h"
29#include <cassert>
30#include <cstddef>
31#include <memory>
32#include <string>
33#include <utility>
34#include <vector>
35
36namespace llvm {
37
38class Triple;
39
40} // namespace llvm
41
42namespace clang {
43
45class DirectoryEntry;
47class FileEntry;
48class FileManager;
49class HeaderSearch;
51class IdentifierInfo;
52class LangOptions;
53class Module;
54class Preprocessor;
55class TargetInfo;
56
57/// The preprocessor keeps track of this information for each
58/// file that is \#included.
60 // TODO: Whether the file was included is not a property of the file itself.
61 // It's a preprocessor state, move it there.
62 /// True if this file has been included (or imported) **locally**.
63 LLVM_PREFERRED_TYPE(bool)
65
66 // TODO: Whether the file was imported is not a property of the file itself.
67 // It's a preprocessor state, move it there.
68 /// True if this is a \#import'd file.
69 LLVM_PREFERRED_TYPE(bool)
70 unsigned isImport : 1;
71
72 /// True if this is a \#pragma once file.
73 LLVM_PREFERRED_TYPE(bool)
74 unsigned isPragmaOnce : 1;
75
76 /// Keep track of whether this is a system header, and if so,
77 /// whether it is C++ clean or not. This can be set by the include paths or
78 /// by \#pragma gcc system_header. This is an instance of
79 /// SrcMgr::CharacteristicKind.
80 LLVM_PREFERRED_TYPE(SrcMgr::CharacteristicKind)
81 unsigned DirInfo : 3;
82
83 /// Whether this header file info was supplied by an external source,
84 /// and has not changed since.
85 LLVM_PREFERRED_TYPE(bool)
86 unsigned External : 1;
87
88 /// Whether this header is part of and built with a module. i.e. it is listed
89 /// in a module map, and is not `excluded` or `textual`. (same meaning as
90 /// `ModuleMap::isModular()`).
91 LLVM_PREFERRED_TYPE(bool)
92 unsigned isModuleHeader : 1;
93
94 /// Whether this header is a `textual header` in a module. If a header is
95 /// textual in one module and normal in another module, this bit will not be
96 /// set, only `isModuleHeader`.
97 LLVM_PREFERRED_TYPE(bool)
99
100 /// Whether this header is part of the module that we are building, even if it
101 /// doesn't build with the module. i.e. this will include `excluded` and
102 /// `textual` headers as well as normal headers.
103 LLVM_PREFERRED_TYPE(bool)
105
106 /// Whether this structure is considered to already have been
107 /// "resolved", meaning that it was loaded from the external source.
108 LLVM_PREFERRED_TYPE(bool)
109 unsigned Resolved : 1;
110
111 /// Whether this file has been looked up as a header.
112 LLVM_PREFERRED_TYPE(bool)
113 unsigned IsValid : 1;
114
115 /// If this file has a \#ifndef XXX (or equivalent) guard that
116 /// protects the entire contents of the file, this is the identifier
117 /// for the macro that controls whether or not it has any effect.
118 ///
119 /// Note: Most clients should use getControllingMacro() to access
120 /// the controlling macro of this header, since
121 /// getControllingMacro() is able to load a controlling macro from
122 /// external storage.
124
130
131 /// Retrieve the controlling macro for this header file, if
132 /// any.
133 const IdentifierInfo *
135
136 /// Update the module membership bits based on the header role.
137 ///
138 /// isModuleHeader will potentially be set, but not cleared.
139 /// isTextualModuleHeader will be set or cleared based on the role update.
141};
142
143static_assert(sizeof(HeaderFileInfo) <= 16);
144
145/// An external source of header file information, which may supply
146/// information about header files already included.
148public:
150
151 /// Retrieve the header file information for the given file entry.
152 ///
153 /// \returns Header file information for the given file entry, with the
154 /// \c External bit set. If the file entry is not known, return a
155 /// default-constructed \c HeaderFileInfo.
157};
158
159/// This structure is used to record entries in our framework cache.
161 /// The directory entry which should be used for the cached framework.
163
164 /// Whether this framework has been "user-specified" to be treated as if it
165 /// were a system framework (even if it was found outside a system framework
166 /// directory).
168};
169
170namespace detail {
171template <bool Const, typename T>
172using Qualified = std::conditional_t<Const, const T, T>;
173
174/// Forward iterator over the search directories of \c HeaderSearch.
175template <bool IsConst>
177 : llvm::iterator_facade_base<SearchDirIteratorImpl<IsConst>,
178 std::forward_iterator_tag,
179 Qualified<IsConst, DirectoryLookup>> {
180 /// Const -> non-const iterator conversion.
181 template <typename Enable = std::enable_if<IsConst, bool>>
184
186
188
189 bool operator==(const SearchDirIteratorImpl &RHS) const {
190 return HS == RHS.HS && Idx == RHS.Idx;
191 }
192
194 assert(*this && "Invalid iterator.");
195 ++Idx;
196 return *this;
197 }
198
200 assert(*this && "Invalid iterator.");
201 return HS->SearchDirs[Idx];
202 }
203
204 /// Creates an invalid iterator.
205 SearchDirIteratorImpl(std::nullptr_t) : HS(nullptr), Idx(0) {}
206
207 /// Checks whether the iterator is valid.
208 explicit operator bool() const { return HS != nullptr; }
209
210private:
211 /// The parent \c HeaderSearch. This is \c nullptr for invalid iterator.
213
214 /// The index of the current element.
215 size_t Idx;
216
217 /// The constructor that creates a valid iterator.
219 : HS(&HS), Idx(Idx) {}
220
221 /// Only HeaderSearch is allowed to instantiate valid iterators.
222 friend HeaderSearch;
223
224 /// Enables const -> non-const conversion.
225 friend SearchDirIteratorImpl<!IsConst>;
226};
227} // namespace detail
228
231
232using ConstSearchDirRange = llvm::iterator_range<ConstSearchDirIterator>;
233using SearchDirRange = llvm::iterator_range<SearchDirIterator>;
234
235/// Encapsulates the information needed to find the file referenced
236/// by a \#include or \#include_next, (sub-)framework lookup, etc.
238 friend class DirectoryLookup;
239
240 friend ConstSearchDirIterator;
241 friend SearchDirIterator;
242
243 /// Header-search options used to initialize this header search.
244 const HeaderSearchOptions &HSOpts;
245
246 /// Mapping from SearchDir to HeaderSearchOptions::UserEntries indices.
247 llvm::DenseMap<unsigned, unsigned> SearchDirToHSEntry;
248
249 DiagnosticsEngine &Diags;
250 FileManager &FileMgr;
251
252 /// \#include search path information. Requests for \#include "x" search the
253 /// directory of the \#including file first, then each directory in SearchDirs
254 /// consecutively. Requests for <x> search the current dir first, then each
255 /// directory in SearchDirs, starting at AngledDirIdx, consecutively.
256 std::vector<DirectoryLookup> SearchDirs;
257 /// Whether the DirectoryLookup at the corresponding index in SearchDirs has
258 /// been successfully used to lookup a file.
259 std::vector<bool> SearchDirsUsage;
260 unsigned AngledDirIdx = 0;
261 unsigned SystemDirIdx = 0;
262
263 /// Maps HeaderMap keys to SearchDir indices. When HeaderMaps are used
264 /// heavily, SearchDirs can start with thousands of HeaderMaps, so this Index
265 /// lets us avoid scanning them all to find a match.
266 llvm::StringMap<unsigned, llvm::BumpPtrAllocator> SearchDirHeaderMapIndex;
267
268 /// The index of the first SearchDir that isn't a header map.
269 unsigned FirstNonHeaderMapSearchDirIdx = 0;
270
271 /// \#include prefixes for which the 'system header' property is
272 /// overridden.
273 ///
274 /// For a \#include "x" or \#include <x> directive, the last string in this
275 /// list which is a prefix of 'x' determines whether the file is treated as
276 /// a system header.
277 std::vector<std::pair<std::string, bool>> SystemHeaderPrefixes;
278
279 /// The context hash used in SpecificModuleCachePath (unless suppressed).
280 std::string ContextHash;
281
282 /// The specific module cache path containing ContextHash (unless suppressed).
283 std::string SpecificModuleCachePath;
284
285 /// All of the preprocessor-specific data about files that are
286 /// included, indexed by the FileEntry's UID.
287 mutable std::vector<HeaderFileInfo> FileInfo;
288
289 /// Keeps track of each lookup performed by LookupFile.
290 struct LookupFileCacheInfo {
291 // The requesting module for the lookup we cached.
292 const Module *RequestingModule = nullptr;
293
294 /// Starting search directory iterator that the cached search was performed
295 /// from. If there is a hit and this value doesn't match the current query,
296 /// the cache has to be ignored.
297 ConstSearchDirIterator StartIt = nullptr;
298
299 /// The search directory iterator that satisfied the query.
300 ConstSearchDirIterator HitIt = nullptr;
301
302 /// This is non-null if the original filename was mapped to a framework
303 /// include via a headermap.
304 const char *MappedName = nullptr;
305
306 /// Default constructor -- Initialize all members with zero.
307 LookupFileCacheInfo() = default;
308
309 void reset(const Module *NewRequestingModule,
310 ConstSearchDirIterator NewStartIt) {
311 RequestingModule = NewRequestingModule;
312 StartIt = NewStartIt;
313 MappedName = nullptr;
314 }
315 };
316 llvm::StringMap<LookupFileCacheInfo, llvm::BumpPtrAllocator> LookupFileCache;
317
318 /// Collection mapping a framework or subframework
319 /// name like "Carbon" to the Carbon.framework directory.
320 llvm::StringMap<FrameworkCacheEntry, llvm::BumpPtrAllocator> FrameworkMap;
321
322 /// Maps include file names (including the quotes or
323 /// angle brackets) to other include file names. This is used to support the
324 /// include_alias pragma for Microsoft compatibility.
325 using IncludeAliasMap =
326 llvm::StringMap<std::string, llvm::BumpPtrAllocator>;
327 std::unique_ptr<IncludeAliasMap> IncludeAliases;
328
329 /// This is a mapping from FileEntry -> HeaderMap, uniquing headermaps.
330 std::vector<std::pair<FileEntryRef, std::unique_ptr<HeaderMap>>> HeaderMaps;
331
332 /// The mapping between modules and headers.
333 mutable ModuleMap ModMap;
334
335 struct ModuleMapDirectoryState {
336 OptionalFileEntryRef ModuleMapFile;
337 OptionalFileEntryRef PrivateModuleMapFile;
338 enum {
339 Parsed,
340 Loaded,
341 Invalid,
342 } Status;
343
344 /// Relative header path -> list of module names
345 llvm::StringMap<llvm::SmallVector<StringRef, 1>> HeaderToModules{};
346 /// Relative dir path -> module name
347 llvm::SmallVector<std::pair<std::string, StringRef>, 2>
348 UmbrellaDirModules{};
349 /// List of module names with umbrella header decls
350 llvm::SmallVector<StringRef, 2> UmbrellaHeaderModules{};
351 };
352
353 /// Describes whether a given directory has a module map in it.
354 llvm::DenseMap<const DirectoryEntry *, ModuleMapDirectoryState>
355 DirectoryModuleMap;
356
357 /// Set of module map files we've already loaded, and a flag indicating
358 /// whether they were valid or not.
359 llvm::DenseMap<const FileEntry *, bool> LoadedModuleMaps;
360
361 /// Set of module map files we've already parsed, and a flag indicating
362 /// whether they were valid or not.
363 llvm::DenseMap<const FileEntry *, bool> ParsedModuleMaps;
364
365 // A map of discovered headers with their associated include file name.
366 llvm::DenseMap<const FileEntry *, llvm::SmallString<64>> IncludeNames;
367
368 /// Uniqued set of framework names, which is used to track which
369 /// headers were included as framework headers.
370 llvm::StringSet<llvm::BumpPtrAllocator> FrameworkNames;
371
372 /// Entity used to resolve the identifier IDs of controlling
373 /// macros into IdentifierInfo pointers, and keep the identifire up to date,
374 /// as needed.
375 ExternalPreprocessorSource *ExternalLookup = nullptr;
376
377 /// Entity used to look up stored header file information.
378 ExternalHeaderFileInfoSource *ExternalSource = nullptr;
379
380 /// Scan all of the header maps at the beginning of SearchDirs and
381 /// map their keys to the SearchDir index of their header map.
382 void indexInitialHeaderMaps();
383
384 /// Build the module map index for a directory's module map.
385 ///
386 /// This fills a ModuleMapDirectoryState with index information from its
387 /// directory's module map.
388 void buildModuleMapIndex(DirectoryEntryRef Dir,
389 ModuleMapDirectoryState &MMState);
390
391 void processModuleMapForIndex(const modulemap::ModuleMapFile &MMF,
392 DirectoryEntryRef MMDir, StringRef PathPrefix,
393 ModuleMapDirectoryState &MMState);
394
395 void processExternModuleDeclForIndex(const modulemap::ExternModuleDecl &EMD,
396 DirectoryEntryRef MMDir,
397 StringRef PathPrefix,
398 ModuleMapDirectoryState &MMState);
399
400 void processModuleDeclForIndex(const modulemap::ModuleDecl &MD,
401 StringRef ModuleName, DirectoryEntryRef MMDir,
402 StringRef PathPrefix,
403 ModuleMapDirectoryState &MMState);
404
405 void addToModuleMapIndex(StringRef RelPath, StringRef ModuleName,
406 StringRef PathPrefix,
407 ModuleMapDirectoryState &MMState);
408
409public:
410 HeaderSearch(const HeaderSearchOptions &HSOpts, SourceManager &SourceMgr,
411 DiagnosticsEngine &Diags, const LangOptions &LangOpts,
412 const TargetInfo *Target);
413 HeaderSearch(const HeaderSearch &) = delete;
415
416 /// Retrieve the header-search options with which this header search
417 /// was initialized.
418 const HeaderSearchOptions &getHeaderSearchOpts() const { return HSOpts; }
419
420 FileManager &getFileMgr() const { return FileMgr; }
421
422 DiagnosticsEngine &getDiags() const { return Diags; }
423
424 /// Interface for setting the file search paths.
425 void SetSearchPaths(std::vector<DirectoryLookup> dirs, unsigned angledDirIdx,
426 unsigned systemDirIdx,
427 llvm::DenseMap<unsigned, unsigned> searchDirToHSEntry);
428
429 /// Add an additional search path.
430 void AddSearchPath(const DirectoryLookup &dir, bool isAngled);
431
432 /// Add an additional system search path.
434 SearchDirs.push_back(dir);
435 SearchDirsUsage.push_back(false);
436 }
437
438 /// Set the list of system header prefixes.
439 void SetSystemHeaderPrefixes(ArrayRef<std::pair<std::string, bool>> P) {
440 SystemHeaderPrefixes.assign(P.begin(), P.end());
441 }
442
443 /// Checks whether the map exists or not.
444 bool HasIncludeAliasMap() const { return (bool)IncludeAliases; }
445
446 /// Map the source include name to the dest include name.
447 ///
448 /// The Source should include the angle brackets or quotes, the dest
449 /// should not. This allows for distinction between <> and "" headers.
450 void AddIncludeAlias(StringRef Source, StringRef Dest) {
451 if (!IncludeAliases)
452 IncludeAliases.reset(new IncludeAliasMap);
453 (*IncludeAliases)[Source] = std::string(Dest);
454 }
455
456 /// Maps one header file name to a different header
457 /// file name, for use with the include_alias pragma. Note that the source
458 /// file name should include the angle brackets or quotes. Returns StringRef
459 /// as null if the header cannot be mapped.
460 StringRef MapHeaderToIncludeAlias(StringRef Source) {
461 assert(IncludeAliases && "Trying to map headers when there's no map");
462
463 // Do any filename replacements before anything else
464 IncludeAliasMap::const_iterator Iter = IncludeAliases->find(Source);
465 if (Iter != IncludeAliases->end())
466 return Iter->second;
467 return {};
468 }
469
470 /// Set the context hash to use for module cache paths.
471 void setContextHash(StringRef Hash) { ContextHash = std::string(Hash); }
472
473 /// Set the module cache path with the context hash (unless suppressed).
474 void setSpecificModuleCachePath(StringRef Path) {
475 SpecificModuleCachePath = std::string(Path);
476 }
477
478 /// Retrieve the context hash.
479 StringRef getContextHash() const { return ContextHash; }
480
481 /// Retrieve the module cache path with the context hash (unless suppressed).
482 StringRef getSpecificModuleCachePath() const {
483 return SpecificModuleCachePath;
484 }
485
486 /// Forget everything we know about headers so far.
488 FileInfo.clear();
489 }
490
492 ExternalLookup = EPS;
493 }
494
496 return ExternalLookup;
497 }
498
499 /// Set the external source of header information.
501 ExternalSource = ES;
502 }
503
505 StringRef Filename, OptionalFileEntryRef FE, bool &DiagnosedShadowing,
506 SourceLocation IncludeLoc, ConstSearchDirIterator FromDir,
507 ArrayRef<std::pair<OptionalFileEntryRef, DirectoryEntryRef>> Includers,
508 bool isAngled, int IncluderLoopIndex, ConstSearchDirIterator MainLoopIt);
509
510 /// Set the target information for the header search, if not
511 /// already known.
512 void setTarget(const TargetInfo &Target);
513
514 /// Given a "foo" or <foo> reference, look up the indicated file,
515 /// return null on failure.
516 ///
517 /// \returns If successful, this returns 'UsedDir', the DirectoryLookup member
518 /// the file was found in, or null if not applicable.
519 ///
520 /// \param IncludeLoc Used for diagnostics if valid.
521 ///
522 /// \param isAngled indicates whether the file reference is a <> reference.
523 ///
524 /// \param CurDir If non-null, the file was found in the specified directory
525 /// search location. This is used to implement \#include_next.
526 ///
527 /// \param Includers Indicates where the \#including file(s) are, in case
528 /// relative searches are needed. In reverse order of inclusion.
529 ///
530 /// \param SearchPath If non-null, will be set to the search path relative
531 /// to which the file was found. If the include path is absolute, SearchPath
532 /// will be set to an empty string.
533 ///
534 /// \param RelativePath If non-null, will be set to the path relative to
535 /// SearchPath at which the file was found. This only differs from the
536 /// Filename for framework includes.
537 ///
538 /// \param SuggestedModule If non-null, and the file found is semantically
539 /// part of a known module, this will be set to the module that should
540 /// be imported instead of preprocessing/parsing the file found.
541 ///
542 /// \param IsMapped If non-null, and the search involved header maps, set to
543 /// true.
544 ///
545 /// \param IsFrameworkFound If non-null, will be set to true if a framework is
546 /// found in any of searched SearchDirs. Will be set to false if a framework
547 /// is found only through header maps. Doesn't guarantee the requested file is
548 /// found.
550 StringRef Filename, SourceLocation IncludeLoc, bool isAngled,
552 ArrayRef<std::pair<OptionalFileEntryRef, DirectoryEntryRef>> Includers,
553 SmallVectorImpl<char> *SearchPath, SmallVectorImpl<char> *RelativePath,
554 Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule,
555 bool *IsMapped, bool *IsFrameworkFound, bool SkipCache = false,
556 bool BuildSystemModule = false, bool OpenFile = true,
557 bool CacheFailures = true);
558
559 /// Look up a subframework for the specified \#include file.
560 ///
561 /// For example, if \#include'ing <HIToolbox/HIToolbox.h> from
562 /// within ".../Carbon.framework/Headers/Carbon.h", check to see if
563 /// HIToolbox is a subframework within Carbon.framework. If so, return
564 /// the FileEntry for the designated file, otherwise return null.
566 StringRef Filename, FileEntryRef ContextFileEnt,
567 SmallVectorImpl<char> *SearchPath, SmallVectorImpl<char> *RelativePath,
568 Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule);
569
570 /// Look up the specified framework name in our framework cache.
571 /// \returns The DirectoryEntry it is in if we know, null otherwise.
573 return FrameworkMap[FWName];
574 }
575
576 /// Mark the specified file as a target of a \#include,
577 /// \#include_next, or \#import directive.
578 ///
579 /// \return false if \#including the file will have no effect or true
580 /// if we should include it.
581 ///
582 /// \param M The module to which `File` belongs (this should usually be the
583 /// SuggestedModule returned by LookupFile/LookupSubframeworkHeader)
585 bool isImport, bool ModulesEnabled, Module *M,
586 bool &IsFirstIncludeOfFile);
587
588 /// Return whether the specified file is a normal header,
589 /// a system header, or a C++ friendly system header.
595
596 /// Mark the specified file as a "once only" file due to
597 /// \#pragma once.
601
602 /// Mark the specified file as a system header, e.g. due to
603 /// \#pragma GCC system_header.
607
608 /// Mark the specified file as part of a module.
610 bool isCompilingModuleHeader);
611
612 /// Mark the specified file as having a controlling macro.
613 ///
614 /// This is used by the multiple-include optimization to eliminate
615 /// no-op \#includes.
617 const IdentifierInfo *ControllingMacro) {
618 getFileInfo(File).LazyControllingMacro = ControllingMacro;
619 }
620
621 /// Determine whether this file is intended to be safe from
622 /// multiple inclusions, e.g., it has \#pragma once or a controlling
623 /// macro.
624 ///
625 /// This routine does not consider the effect of \#import
627
628 /// Determine whether the given file is known to have ever been \#imported.
631 return FI && FI->isImport;
632 }
633
634 /// Determine which HeaderSearchOptions::UserEntries have been successfully
635 /// used so far and mark their index with 'true' in the resulting bit vector.
636 /// Note: implicit module maps don't contribute to entry usage.
637 std::vector<bool> computeUserEntryUsage() const;
638
639 /// Collect which HeaderSearchOptions::VFSOverlayFiles have been meaningfully
640 /// used so far and mark their index with 'true' in the resulting bit vector.
641 ///
642 /// Note: this ignores VFSs that redirect non-affecting files such as unused
643 /// modulemaps.
644 std::vector<bool> collectVFSUsageAndClear() const;
645
646 /// This method returns a HeaderMap for the specified
647 /// FileEntry, uniquing them through the 'HeaderMaps' datastructure.
649
650 /// Get filenames for all registered header maps.
652
653 /// Retrieve the name of the cached module file that should be used
654 /// to load the given module.
655 ///
656 /// \param Module The module whose module file name will be returned.
657 ///
658 /// \returns The name of the module file that corresponds to this module,
659 /// or an empty string if this module does not correspond to any module file.
661
662 /// Retrieve the name of the prebuilt module file that should be used
663 /// to load a module with the given name.
664 ///
665 /// \param ModuleName The module whose module file name will be returned.
666 ///
667 /// \param FileMapOnly If true, then only look in the explicit module name
668 // to file name map and skip the directory search.
669 ///
670 /// \returns The name of the module file that corresponds to this module,
671 /// or an empty string if this module does not correspond to any module file.
672 std::string getPrebuiltModuleFileName(StringRef ModuleName,
673 bool FileMapOnly = false);
674
675 /// Retrieve the name of the prebuilt module file that should be used
676 /// to load the given module.
677 ///
678 /// \param Module The module whose module file name will be returned.
679 ///
680 /// \returns The name of the module file that corresponds to this module,
681 /// or an empty string if this module does not correspond to any module file.
683
684 /// Retrieve the name of the (to-be-)cached module file that should
685 /// be used to load a module with the given name.
686 ///
687 /// \param ModuleName The module whose module file name will be returned.
688 ///
689 /// \param ModuleMapPath A path that when combined with \c ModuleName
690 /// uniquely identifies this module. See Module::ModuleMap.
691 ///
692 /// \returns The name of the module file that corresponds to this module,
693 /// or an empty string if this module does not correspond to any module file.
694 std::string getCachedModuleFileName(StringRef ModuleName,
695 StringRef ModuleMapPath);
696
697 /// Lookup a module Search for a module with the given name.
698 ///
699 /// \param ModuleName The name of the module we're looking for.
700 ///
701 /// \param ImportLoc Location of the module include/import.
702 ///
703 /// \param AllowSearch Whether we are allowed to search in the various
704 /// search directories to produce a module definition. If not, this lookup
705 /// will only return an already-known module.
706 ///
707 /// \param AllowExtraModuleMapSearch Whether we allow to search modulemaps
708 /// in subdirectories.
709 ///
710 /// \returns The module with the given name.
711 Module *lookupModule(StringRef ModuleName,
712 SourceLocation ImportLoc = SourceLocation(),
713 bool AllowSearch = true,
714 bool AllowExtraModuleMapSearch = false);
715
716 /// Try to find a module map file in the given directory, returning
717 /// \c nullopt if none is found.
719 bool IsFramework);
720
721 /// Determine whether there is a module map that may map the header
722 /// with the given file name to a (sub)module.
723 /// Always returns false if modules are disabled.
724 ///
725 /// \param Filename The name of the file.
726 ///
727 /// \param Root The "root" directory, at which we should stop looking for
728 /// module maps.
729 ///
730 /// \param IsSystem Whether the directories we're looking at are system
731 /// header directories.
732 bool hasModuleMap(StringRef Filename, const DirectoryEntry *Root,
733 bool IsSystem);
734
735 /// Retrieve the module that corresponds to the given file, if any.
736 ///
737 /// \param File The header that we wish to map to a module.
738 /// \param AllowTextual Whether we want to find textual headers too.
740 bool AllowTextual = false,
741 bool AllowExcluded = false) const;
742
743 /// Retrieve all the modules corresponding to the given file.
744 ///
745 /// \ref findModuleForHeader should typically be used instead of this.
748
749 /// Like \ref findAllModulesForHeader, but do not attempt to infer module
750 /// ownership from umbrella headers if we've not already done so.
753
754 /// Read the contents of the given module map file.
755 ///
756 /// \param File The module map file.
757 /// \param IsSystem Whether this file is in a system header directory.
758 /// \param ID If the module map file is already mapped (perhaps as part of
759 /// processing a preprocessed module), the ID of the file.
760 /// \param Offset [inout] An offset within ID to start parsing. On exit,
761 /// filled by the end of the parsed contents (either EOF or the
762 /// location of an end-of-module-map pragma).
763 /// \param OriginalModuleMapFile The original path to the module map file,
764 /// used to resolve paths within the module (this is required when
765 /// building the module from preprocessed source).
766 /// \returns true if an error occurred, false otherwise.
767 bool parseAndLoadModuleMapFile(FileEntryRef File, bool IsSystem,
768 FileID ID = FileID(),
769 unsigned *Offset = nullptr,
770 StringRef OriginalModuleMapFile = StringRef());
771
772 /// Collect the set of all known, top-level modules.
773 ///
774 /// \param Modules Will be filled with the set of known, top-level modules.
776
777 /// Load all known, top-level system modules.
779
780private:
781 /// Lookup a module with the given module name and search-name.
782 ///
783 /// \param ModuleName The name of the module we're looking for.
784 ///
785 /// \param SearchName The "search-name" to derive filesystem paths from
786 /// when looking for the module map; this is usually equal to ModuleName,
787 /// but for compatibility with some buggy frameworks, additional attempts
788 /// may be made to find the module under a related-but-different search-name.
789 ///
790 /// \param ImportLoc Location of the module include/import.
791 ///
792 /// \param AllowExtraModuleMapSearch Whether we allow to search modulemaps
793 /// in subdirectories.
794 ///
795 /// \returns The module named ModuleName.
796 Module *lookupModule(StringRef ModuleName, StringRef SearchName,
797 SourceLocation ImportLoc,
798 bool AllowExtraModuleMapSearch = false);
799
800 /// Retrieve the name of the (to-be-)cached module file that should
801 /// be used to load a module with the given name.
802 ///
803 /// \param ModuleName The module whose module file name will be returned.
804 ///
805 /// \param ModuleMapPath A path that when combined with \c ModuleName
806 /// uniquely identifies this module. See Module::ModuleMap.
807 ///
808 /// \param CachePath A path to the module cache.
809 ///
810 /// \returns The name of the module file that corresponds to this module,
811 /// or an empty string if this module does not correspond to any module file.
812 std::string getCachedModuleFileNameImpl(StringRef ModuleName,
813 StringRef ModuleMapPath,
814 StringRef CachePath);
815
816 /// Retrieve a module with the given name, which may be part of the
817 /// given framework.
818 ///
819 /// \param Name The name of the module to retrieve.
820 ///
821 /// \param Dir The framework directory (e.g., ModuleName.framework).
822 ///
823 /// \param IsSystem Whether the framework directory is part of the system
824 /// frameworks.
825 ///
826 /// \returns The module, if found; otherwise, null.
827 Module *loadFrameworkModule(StringRef Name, DirectoryEntryRef Dir,
828 bool IsSystem);
829
830 /// Load all of the module maps within the immediate subdirectories
831 /// of the given search directory.
832 void loadSubdirectoryModuleMaps(DirectoryLookup &SearchDir);
833
834 /// Find and suggest a usable module for the given file.
835 ///
836 /// \return \c true if the file can be used, \c false if we are not permitted to
837 /// find this file due to requirements from \p RequestingModule.
838 bool findUsableModuleForHeader(FileEntryRef File, const DirectoryEntry *Root,
839 Module *RequestingModule,
840 ModuleMap::KnownHeader *SuggestedModule,
841 bool IsSystemHeaderDir);
842
843 /// Find and suggest a usable module for the given file, which is part of
844 /// the specified framework.
845 ///
846 /// \return \c true if the file can be used, \c false if we are not permitted to
847 /// find this file due to requirements from \p RequestingModule.
848 bool findUsableModuleForFrameworkHeader(
849 FileEntryRef File, StringRef FrameworkName, Module *RequestingModule,
850 ModuleMap::KnownHeader *SuggestedModule, bool IsSystemFramework);
851
852 /// Look up the file with the specified name and determine its owning
853 /// module.
855 getFileAndSuggestModule(StringRef FileName, SourceLocation IncludeLoc,
856 const DirectoryEntry *Dir, bool IsSystemHeaderDir,
857 Module *RequestingModule,
858 ModuleMap::KnownHeader *SuggestedModule,
859 bool OpenFile = true, bool CacheFailures = true);
860
861 /// Cache the result of a successful lookup at the given include location
862 /// using the search path at \c HitIt.
863 void cacheLookupSuccess(LookupFileCacheInfo &CacheLookup,
865 SourceLocation IncludeLoc);
866
867 /// Note that a lookup at the given include location was successful using the
868 /// search path at index `HitIdx`.
869 void noteLookupUsage(unsigned HitIdx, SourceLocation IncludeLoc);
870
871public:
872 /// Retrieve the module map.
873 ModuleMap &getModuleMap() { return ModMap; }
874
875 /// Retrieve the module map.
876 const ModuleMap &getModuleMap() const { return ModMap; }
877
878 unsigned header_file_size() const { return FileInfo.size(); }
879
880 /// Return the HeaderFileInfo structure for the specified FileEntry, in
881 /// preparation for updating it in some way.
883
884 /// Return the HeaderFileInfo structure for the specified FileEntry, if it has
885 /// ever been filled in (either locally or externally).
887
888 /// Return the headerFileInfo structure for the specified FileEntry, if it has
889 /// ever been filled in locally.
891
892 SearchDirIterator search_dir_begin() { return {*this, 0}; }
893 SearchDirIterator search_dir_end() { return {*this, SearchDirs.size()}; }
897
898 ConstSearchDirIterator search_dir_begin() const { return quoted_dir_begin(); }
899 ConstSearchDirIterator search_dir_nth(size_t n) const {
900 assert(n < SearchDirs.size());
901 return {*this, n};
902 }
903 ConstSearchDirIterator search_dir_end() const { return system_dir_end(); }
907
908 unsigned search_dir_size() const { return SearchDirs.size(); }
909
910 ConstSearchDirIterator quoted_dir_begin() const { return {*this, 0}; }
911 ConstSearchDirIterator quoted_dir_end() const { return angled_dir_begin(); }
912
913 ConstSearchDirIterator angled_dir_begin() const {
914 return {*this, AngledDirIdx};
915 }
916 ConstSearchDirIterator angled_dir_end() const { return system_dir_begin(); }
917
918 ConstSearchDirIterator system_dir_begin() const {
919 return {*this, SystemDirIdx};
920 }
921 ConstSearchDirIterator system_dir_end() const {
922 return {*this, SearchDirs.size()};
923 }
924
925 /// Get the index of the given search directory.
926 unsigned searchDirIdx(const DirectoryLookup &DL) const;
927
928 /// Retrieve a uniqued framework name.
929 StringRef getUniqueFrameworkName(StringRef Framework);
930
931 /// Retrieve the include name for the header.
932 ///
933 /// \param File The entry for a given header.
934 /// \returns The name of how the file was included when the header's location
935 /// was resolved.
936 StringRef getIncludeNameForHeader(const FileEntry *File) const;
937
938 /// Suggest a path by which the specified file could be found, for use in
939 /// diagnostics to suggest a #include. Returned path will only contain forward
940 /// slashes as separators. MainFile is the absolute path of the file that we
941 /// are generating the diagnostics for. It will try to shorten the path using
942 /// MainFile location, if none of the include search directories were prefix
943 /// of File.
944 ///
945 /// \param IsAngled If non-null, filled in to indicate whether the suggested
946 /// path should be referenced as <Header.h> instead of "Header.h".
948 llvm::StringRef MainFile,
949 bool *IsAngled = nullptr) const;
950
951 /// Suggest a path by which the specified file could be found, for use in
952 /// diagnostics to suggest a #include. Returned path will only contain forward
953 /// slashes as separators. MainFile is the absolute path of the file that we
954 /// are generating the diagnostics for. It will try to shorten the path using
955 /// MainFile location, if none of the include search directories were prefix
956 /// of File.
957 ///
958 /// \param WorkingDir If non-empty, this will be prepended to search directory
959 /// paths that are relative.
960 std::string suggestPathToFileForDiagnostics(llvm::StringRef File,
961 llvm::StringRef WorkingDir,
962 llvm::StringRef MainFile,
963 bool *IsAngled = nullptr) const;
964
965 void PrintStats();
966
967 size_t getTotalMemory() const;
968
969private:
970 /// Describes what happened when we tried to load or parse a module map file.
971 enum ModuleMapResult {
972 /// The module map file had already been processed.
973 MMR_AlreadyProcessed,
974
975 /// The module map file was processed by this invocation.
976 MMR_NewlyProcessed,
977
978 /// There is was directory with the given name.
979 MMR_NoDirectory,
980
981 /// There was either no module map file or the module map file was
982 /// invalid.
983 MMR_InvalidModuleMap
984 };
985
986 ModuleMapResult parseAndLoadModuleMapFileImpl(FileEntryRef File,
987 bool IsSystem,
988 DirectoryEntryRef Dir,
989 FileID ID = FileID(),
990 unsigned *Offset = nullptr,
991 bool DiagnosePrivMMap = false);
992
993 ModuleMapResult parseModuleMapFileImpl(FileEntryRef File, bool IsSystem,
994 DirectoryEntryRef Dir,
995 FileID ID = FileID());
996
997 /// Try to load the module map file in the given directory.
998 ///
999 /// \param DirName The name of the directory where we will look for a module
1000 /// map file.
1001 /// \param IsSystem Whether this is a system header directory.
1002 /// \param IsFramework Whether this is a framework directory.
1003 ///
1004 /// \returns The result of attempting to load the module map file from the
1005 /// named directory.
1006 ModuleMapResult parseAndLoadModuleMapFile(StringRef DirName, bool IsSystem,
1007 bool IsFramework);
1008
1009 /// Try to load the module map file in the given directory.
1010 ///
1011 /// \param Dir The directory where we will look for a module map file.
1012 /// \param IsSystem Whether this is a system header directory.
1013 /// \param IsFramework Whether this is a framework directory.
1014 ///
1015 /// \returns The result of attempting to load the module map file from the
1016 /// named directory.
1017 ModuleMapResult parseAndLoadModuleMapFile(DirectoryEntryRef Dir,
1018 bool IsSystem, bool IsFramework);
1019
1020 ModuleMapResult parseModuleMapFile(StringRef DirName, bool IsSystem,
1021 bool IsFramework);
1022 ModuleMapResult parseModuleMapFile(DirectoryEntryRef Dir, bool IsSystem,
1023 bool IsFramework);
1024};
1025
1026/// Apply the header search options to get given HeaderSearch object.
1028 const HeaderSearchOptions &HSOpts,
1029 const LangOptions &Lang,
1030 const llvm::Triple &triple);
1031
1032void normalizeModuleCachePath(FileManager &FileMgr, StringRef Path,
1033 SmallVectorImpl<char> &NormalizedPath);
1034
1035} // namespace clang
1036
1037#endif // LLVM_CLANG_LEX_HEADERSEARCH_H
std::shared_ptr< TokenRole > Role
A token can have a special role that can carry extra information about the token's formatting.
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
Concrete class used by the front-end to report problems and issues.
Definition Diagnostic.h:232
A reference to a DirectoryEntry that includes the name of the directory as it was accessed by the Fil...
Cached information about one directory (either on disk or in the virtual file system).
DirectoryLookup - This class represents one entry in the search list that specifies the search order ...
An external source of header file information, which may supply information about header files alread...
virtual HeaderFileInfo GetHeaderFileInfo(FileEntryRef FE)=0
Retrieve the header file information for the given file entry.
Abstract interface for external sources of preprocessor information.
A reference to a FileEntry that includes the name of the file as it was accessed by the FileManager's...
Definition FileEntry.h:57
Cached information about one file (either on disk or in the virtual file system).
Definition FileEntry.h:302
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Implements support for file system lookup, file system caching, and directory search management.
Definition FileManager.h:53
This class represents an Apple concept known as a 'header map'.
Definition HeaderMap.h:84
HeaderSearchOptions - Helper class for storing options related to the initialization of the HeaderSea...
Encapsulates the information needed to find the file referenced by a #include or #include_next,...
StringRef getUniqueFrameworkName(StringRef Framework)
Retrieve a uniqued framework name.
void SetExternalSource(ExternalHeaderFileInfoSource *ES)
Set the external source of header information.
HeaderSearch & operator=(const HeaderSearch &)=delete
unsigned search_dir_size() const
std::vector< bool > collectVFSUsageAndClear() const
Collect which HeaderSearchOptions::VFSOverlayFiles have been meaningfully used so far and mark their ...
SrcMgr::CharacteristicKind getFileDirFlavor(FileEntryRef File)
Return whether the specified file is a normal header, a system header, or a C++ friendly system heade...
FileManager & getFileMgr() const
void AddSearchPath(const DirectoryLookup &dir, bool isAngled)
Add an additional search path.
void diagnoseHeaderShadowing(StringRef Filename, OptionalFileEntryRef FE, bool &DiagnosedShadowing, SourceLocation IncludeLoc, ConstSearchDirIterator FromDir, ArrayRef< std::pair< OptionalFileEntryRef, DirectoryEntryRef > > Includers, bool isAngled, int IncluderLoopIndex, ConstSearchDirIterator MainLoopIt)
ConstSearchDirIterator angled_dir_end() const
Module * lookupModule(StringRef ModuleName, SourceLocation ImportLoc=SourceLocation(), bool AllowSearch=true, bool AllowExtraModuleMapSearch=false)
Lookup a module Search for a module with the given name.
void SetFileControllingMacro(FileEntryRef File, const IdentifierInfo *ControllingMacro)
Mark the specified file as having a controlling macro.
DiagnosticsEngine & getDiags() const
void MarkFileIncludeOnce(FileEntryRef File)
Mark the specified file as a "once only" file due to #pragma once.
ConstSearchDirIterator system_dir_begin() const
HeaderSearch(const HeaderSearch &)=delete
friend class DirectoryLookup
bool hasModuleMap(StringRef Filename, const DirectoryEntry *Root, bool IsSystem)
Determine whether there is a module map that may map the header with the given file name to a (sub)mo...
std::string suggestPathToFileForDiagnostics(FileEntryRef File, llvm::StringRef MainFile, bool *IsAngled=nullptr) const
Suggest a path by which the specified file could be found, for use in diagnostics to suggest a includ...
const HeaderFileInfo * getExistingLocalFileInfo(FileEntryRef FE) const
Return the headerFileInfo structure for the specified FileEntry, if it has ever been filled in locall...
ConstSearchDirIterator search_dir_end() const
OptionalFileEntryRef LookupFile(StringRef Filename, SourceLocation IncludeLoc, bool isAngled, ConstSearchDirIterator FromDir, ConstSearchDirIterator *CurDir, ArrayRef< std::pair< OptionalFileEntryRef, DirectoryEntryRef > > Includers, SmallVectorImpl< char > *SearchPath, SmallVectorImpl< char > *RelativePath, Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule, bool *IsMapped, bool *IsFrameworkFound, bool SkipCache=false, bool BuildSystemModule=false, bool OpenFile=true, bool CacheFailures=true)
Given a "foo" or <foo> reference, look up the indicated file, return null on failure.
void getHeaderMapFileNames(SmallVectorImpl< std::string > &Names) const
Get filenames for all registered header maps.
void MarkFileSystemHeader(FileEntryRef File)
Mark the specified file as a system header, e.g.
StringRef getIncludeNameForHeader(const FileEntry *File) const
Retrieve the include name for the header.
std::string getPrebuiltImplicitModuleFileName(Module *Module)
Retrieve the name of the prebuilt module file that should be used to load the given module.
ConstSearchDirIterator angled_dir_begin() const
void SetSystemHeaderPrefixes(ArrayRef< std::pair< std::string, bool > > P)
Set the list of system header prefixes.
ArrayRef< ModuleMap::KnownHeader > findAllModulesForHeader(FileEntryRef File) const
Retrieve all the modules corresponding to the given file.
ConstSearchDirRange search_dir_range() const
bool hasFileBeenImported(FileEntryRef File) const
Determine whether the given file is known to have ever been #imported.
unsigned searchDirIdx(const DirectoryLookup &DL) const
Get the index of the given search directory.
bool isFileMultipleIncludeGuarded(FileEntryRef File) const
Determine whether this file is intended to be safe from multiple inclusions, e.g.,...
ConstSearchDirIterator quoted_dir_begin() const
ExternalPreprocessorSource * getExternalLookup() const
ConstSearchDirIterator search_dir_nth(size_t n) const
bool parseAndLoadModuleMapFile(FileEntryRef File, bool IsSystem, FileID ID=FileID(), unsigned *Offset=nullptr, StringRef OriginalModuleMapFile=StringRef())
Read the contents of the given module map file.
void loadTopLevelSystemModules()
Load all known, top-level system modules.
SearchDirIterator search_dir_end()
FrameworkCacheEntry & LookupFrameworkCache(StringRef FWName)
Look up the specified framework name in our framework cache.
std::vector< bool > computeUserEntryUsage() const
Determine which HeaderSearchOptions::UserEntries have been successfully used so far and mark their in...
ConstSearchDirIterator quoted_dir_end() const
ArrayRef< ModuleMap::KnownHeader > findResolvedModulesForHeader(FileEntryRef File) const
Like findAllModulesForHeader, but do not attempt to infer module ownership from umbrella headers if w...
void SetSearchPaths(std::vector< DirectoryLookup > dirs, unsigned angledDirIdx, unsigned systemDirIdx, llvm::DenseMap< unsigned, unsigned > searchDirToHSEntry)
Interface for setting the file search paths.
const ModuleMap & getModuleMap() const
Retrieve the module map.
void setTarget(const TargetInfo &Target)
Set the target information for the header search, if not already known.
const HeaderMap * CreateHeaderMap(FileEntryRef FE)
This method returns a HeaderMap for the specified FileEntry, uniquing them through the 'HeaderMaps' d...
ModuleMap::KnownHeader findModuleForHeader(FileEntryRef File, bool AllowTextual=false, bool AllowExcluded=false) const
Retrieve the module that corresponds to the given file, if any.
const HeaderSearchOptions & getHeaderSearchOpts() const
Retrieve the header-search options with which this header search was initialized.
SearchDirRange search_dir_range()
void setContextHash(StringRef Hash)
Set the context hash to use for module cache paths.
std::string getCachedModuleFileName(Module *Module)
Retrieve the name of the cached module file that should be used to load the given module.
void collectAllModules(SmallVectorImpl< Module * > &Modules)
Collect the set of all known, top-level modules.
void MarkFileModuleHeader(FileEntryRef FE, ModuleMap::ModuleHeaderRole Role, bool isCompilingModuleHeader)
Mark the specified file as part of a module.
const HeaderFileInfo * getExistingFileInfo(FileEntryRef FE) const
Return the HeaderFileInfo structure for the specified FileEntry, if it has ever been filled in (eithe...
OptionalFileEntryRef LookupSubframeworkHeader(StringRef Filename, FileEntryRef ContextFileEnt, SmallVectorImpl< char > *SearchPath, SmallVectorImpl< char > *RelativePath, Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule)
Look up a subframework for the specified #include file.
HeaderFileInfo & getFileInfo(FileEntryRef FE)
Return the HeaderFileInfo structure for the specified FileEntry, in preparation for updating it in so...
void SetExternalLookup(ExternalPreprocessorSource *EPS)
StringRef getSpecificModuleCachePath() const
Retrieve the module cache path with the context hash (unless suppressed).
OptionalFileEntryRef lookupModuleMapFile(DirectoryEntryRef Dir, bool IsFramework)
Try to find a module map file in the given directory, returning nullopt if none is found.
bool ShouldEnterIncludeFile(Preprocessor &PP, FileEntryRef File, bool isImport, bool ModulesEnabled, Module *M, bool &IsFirstIncludeOfFile)
Mark the specified file as a target of a #include, #include_next, or #import directive.
size_t getTotalMemory() const
ModuleMap & getModuleMap()
Retrieve the module map.
bool HasIncludeAliasMap() const
Checks whether the map exists or not.
std::string getPrebuiltModuleFileName(StringRef ModuleName, bool FileMapOnly=false)
Retrieve the name of the prebuilt module file that should be used to load a module with the given nam...
unsigned header_file_size() const
HeaderSearch(const HeaderSearchOptions &HSOpts, SourceManager &SourceMgr, DiagnosticsEngine &Diags, const LangOptions &LangOpts, const TargetInfo *Target)
ConstSearchDirIterator system_dir_end() const
void ClearFileInfo()
Forget everything we know about headers so far.
void setSpecificModuleCachePath(StringRef Path)
Set the module cache path with the context hash (unless suppressed).
ConstSearchDirIterator search_dir_begin() const
void AddIncludeAlias(StringRef Source, StringRef Dest)
Map the source include name to the dest include name.
StringRef MapHeaderToIncludeAlias(StringRef Source)
Maps one header file name to a different header file name, for use with the include_alias pragma.
StringRef getContextHash() const
Retrieve the context hash.
SearchDirIterator search_dir_begin()
void AddSystemSearchPath(const DirectoryLookup &dir)
Add an additional system search path.
One of these records is kept for each identifier that is lexed.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
A header that is known to reside within a given module, whether it was included or excluded.
Definition ModuleMap.h:158
ModuleHeaderRole
Flags describing the role of a module header.
Definition ModuleMap.h:126
Describes a module or submodule.
Definition Module.h:144
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Encodes a location in the source.
Exposes information about the current target.
Definition TargetInfo.h:226
#define bool
Definition gpuintrin.h:32
Public enums and private classes that are part of the SourceManager implementation.
CharacteristicKind
Indicates whether a file or directory holds normal user code, system code, or system code which is im...
std::conditional_t< Const, const T, T > Qualified
The JSON file list parser is used to communicate input to InstallAPI.
CustomizableOptional< FileEntryRef > OptionalFileEntryRef
Definition FileEntry.h:208
void ApplyHeaderSearchOptions(HeaderSearch &HS, const HeaderSearchOptions &HSOpts, const LangOptions &Lang, const llvm::Triple &triple)
Apply the header search options to get given HeaderSearch object.
detail::SearchDirIteratorImpl< true > ConstSearchDirIterator
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
detail::SearchDirIteratorImpl< false > SearchDirIterator
@ External
External linkage, which indicates that the entity can be referred to from other translation units.
Definition Linkage.h:58
llvm::iterator_range< ConstSearchDirIterator > ConstSearchDirRange
void normalizeModuleCachePath(FileManager &FileMgr, StringRef Path, SmallVectorImpl< char > &NormalizedPath)
llvm::iterator_range< SearchDirIterator > SearchDirRange
CustomizableOptional< DirectoryEntryRef > OptionalDirectoryEntryRef
@ Other
Other implicit parameter.
Definition Decl.h:1746
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
#define false
Definition stdbool.h:26
This structure is used to record entries in our framework cache.
bool IsUserSpecifiedSystemFramework
Whether this framework has been "user-specified" to be treated as if it were a system framework (even...
OptionalDirectoryEntryRef Directory
The directory entry which should be used for the cached framework.
The preprocessor keeps track of this information for each file that is #included.
void mergeModuleMembership(ModuleMap::ModuleHeaderRole Role)
Update the module membership bits based on the header role.
LazyIdentifierInfoPtr LazyControllingMacro
If this file has a #ifndef XXX (or equivalent) guard that protects the entire contents of the file,...
unsigned DirInfo
Keep track of whether this is a system header, and if so, whether it is C++ clean or not.
unsigned isModuleHeader
Whether this header is part of and built with a module.
const IdentifierInfo * getControllingMacro(ExternalPreprocessorSource *External)
Retrieve the controlling macro for this header file, if any.
unsigned isTextualModuleHeader
Whether this header is a textual header in a module.
unsigned isPragmaOnce
True if this is a #pragma once file.
unsigned Resolved
Whether this structure is considered to already have been "resolved", meaning that it was loaded from...
unsigned isCompilingModuleHeader
Whether this header is part of the module that we are building, even if it doesn't build with the mod...
unsigned IsValid
Whether this file has been looked up as a header.
unsigned isImport
True if this is a #import'd file.
unsigned IsLocallyIncluded
True if this file has been included (or imported) locally.
unsigned External
Whether this header file info was supplied by an external source, and has not changed since.
Forward iterator over the search directories of HeaderSearch.
SearchDirIteratorImpl(std::nullptr_t)
Creates an invalid iterator.
Qualified< IsConst, DirectoryLookup > & operator*() const
bool operator==(const SearchDirIteratorImpl &RHS) const
SearchDirIteratorImpl(const SearchDirIteratorImpl< false > &Other)
Const -> non-const iterator conversion.
SearchDirIteratorImpl & operator++()
SearchDirIteratorImpl & operator=(const SearchDirIteratorImpl &)=default
SearchDirIteratorImpl(const SearchDirIteratorImpl &)=default