clang  14.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 
19 #include "clang/Lex/HeaderMap.h"
20 #include "clang/Lex/ModuleMap.h"
21 #include "llvm/ADT/ArrayRef.h"
22 #include "llvm/ADT/DenseMap.h"
23 #include "llvm/ADT/SetVector.h"
24 #include "llvm/ADT/SmallSet.h"
25 #include "llvm/ADT/SmallString.h"
26 #include "llvm/ADT/StringMap.h"
27 #include "llvm/ADT/StringRef.h"
28 #include "llvm/ADT/StringSet.h"
29 #include "llvm/Support/Allocator.h"
30 #include <cassert>
31 #include <cstddef>
32 #include <memory>
33 #include <string>
34 #include <utility>
35 #include <vector>
36 
37 namespace clang {
38 
39 class DiagnosticsEngine;
40 class DirectoryEntry;
41 class ExternalPreprocessorSource;
42 class FileEntry;
43 class FileManager;
44 class HeaderSearchOptions;
45 class IdentifierInfo;
46 class LangOptions;
47 class Module;
48 class Preprocessor;
49 class TargetInfo;
50 
51 /// The preprocessor keeps track of this information for each
52 /// file that is \#included.
54  /// True if this is a \#import'd file.
55  unsigned isImport : 1;
56 
57  /// True if this is a \#pragma once file.
58  unsigned isPragmaOnce : 1;
59 
60  /// Keep track of whether this is a system header, and if so,
61  /// whether it is C++ clean or not. This can be set by the include paths or
62  /// by \#pragma gcc system_header. This is an instance of
63  /// SrcMgr::CharacteristicKind.
64  unsigned DirInfo : 3;
65 
66  /// Whether this header file info was supplied by an external source,
67  /// and has not changed since.
68  unsigned External : 1;
69 
70  /// Whether this header is part of a module.
71  unsigned isModuleHeader : 1;
72 
73  /// Whether this header is part of the module that we are building.
75 
76  /// Whether this structure is considered to already have been
77  /// "resolved", meaning that it was loaded from the external source.
78  unsigned Resolved : 1;
79 
80  /// Whether this is a header inside a framework that is currently
81  /// being built.
82  ///
83  /// When a framework is being built, the headers have not yet been placed
84  /// into the appropriate framework subdirectories, and therefore are
85  /// provided via a header map. This bit indicates when this is one of
86  /// those framework headers.
87  unsigned IndexHeaderMapHeader : 1;
88 
89  /// Whether this file has been looked up as a header.
90  unsigned IsValid : 1;
91 
92  /// The number of times the file has been included already.
93  unsigned short NumIncludes = 0;
94 
95  /// The ID number of the controlling macro.
96  ///
97  /// This ID number will be non-zero when there is a controlling
98  /// macro whose IdentifierInfo may not yet have been loaded from
99  /// external storage.
100  unsigned ControllingMacroID = 0;
101 
102  /// If this file has a \#ifndef XXX (or equivalent) guard that
103  /// protects the entire contents of the file, this is the identifier
104  /// for the macro that controls whether or not it has any effect.
105  ///
106  /// Note: Most clients should use getControllingMacro() to access
107  /// the controlling macro of this header, since
108  /// getControllingMacro() is able to load a controlling macro from
109  /// external storage.
111 
112  /// If this header came from a framework include, this is the name
113  /// of the framework.
114  StringRef Framework;
115 
116  /// List of aliases that this header is known as.
117  /// Most headers should only have at most one alias, but a handful
118  /// have two.
119  llvm::SetVector<llvm::SmallString<32>,
121  llvm::SmallSet<llvm::SmallString<32>, 2>>
123 
128 
129  /// Retrieve the controlling macro for this header file, if
130  /// any.
131  const IdentifierInfo *
133 
134  /// Determine whether this is a non-default header file info, e.g.,
135  /// it corresponds to an actual header we've included or tried to include.
136  bool isNonDefault() const {
139  }
140 };
141 
142 /// An external source of header file information, which may supply
143 /// information about header files already included.
145 public:
147 
148  /// Retrieve the header file information for the given file entry.
149  ///
150  /// \returns Header file information for the given file entry, with the
151  /// \c External bit set. If the file entry is not known, return a
152  /// default-constructed \c HeaderFileInfo.
153  virtual HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE) = 0;
154 };
155 
156 /// This structure is used to record entries in our framework cache.
158  /// The directory entry which should be used for the cached framework.
160 
161  /// Whether this framework has been "user-specified" to be treated as if it
162  /// were a system framework (even if it was found outside a system framework
163  /// directory).
165 };
166 
167 /// Encapsulates the information needed to find the file referenced
168 /// by a \#include or \#include_next, (sub-)framework lookup, etc.
170  friend class DirectoryLookup;
171 
172  /// Header-search options used to initialize this header search.
173  std::shared_ptr<HeaderSearchOptions> HSOpts;
174 
175  /// Mapping from SearchDir to HeaderSearchOptions::UserEntries indices.
176  llvm::DenseMap<unsigned, unsigned> SearchDirToHSEntry;
177 
178  DiagnosticsEngine &Diags;
179  FileManager &FileMgr;
180 
181  /// \#include search path information. Requests for \#include "x" search the
182  /// directory of the \#including file first, then each directory in SearchDirs
183  /// consecutively. Requests for <x> search the current dir first, then each
184  /// directory in SearchDirs, starting at AngledDirIdx, consecutively. If
185  /// NoCurDirSearch is true, then the check for the file in the current
186  /// directory is suppressed.
187  std::vector<DirectoryLookup> SearchDirs;
188  /// Whether the DirectoryLookup at the corresponding index in SearchDirs has
189  /// been successfully used to lookup a file.
190  std::vector<bool> SearchDirsUsage;
191  unsigned AngledDirIdx = 0;
192  unsigned SystemDirIdx = 0;
193  bool NoCurDirSearch = false;
194 
195  /// \#include prefixes for which the 'system header' property is
196  /// overridden.
197  ///
198  /// For a \#include "x" or \#include <x> directive, the last string in this
199  /// list which is a prefix of 'x' determines whether the file is treated as
200  /// a system header.
201  std::vector<std::pair<std::string, bool>> SystemHeaderPrefixes;
202 
203  /// The hash used for module cache paths.
204  std::string ModuleHash;
205 
206  /// The path to the module cache.
207  std::string ModuleCachePath;
208 
209  /// All of the preprocessor-specific data about files that are
210  /// included, indexed by the FileEntry's UID.
211  mutable std::vector<HeaderFileInfo> FileInfo;
212 
213  /// Keeps track of each lookup performed by LookupFile.
214  struct LookupFileCacheInfo {
215  /// Starting index in SearchDirs that the cached search was performed from.
216  /// If there is a hit and this value doesn't match the current query, the
217  /// cache has to be ignored.
218  unsigned StartIdx = 0;
219 
220  /// The entry in SearchDirs that satisfied the query.
221  unsigned HitIdx = 0;
222 
223  /// This is non-null if the original filename was mapped to a framework
224  /// include via a headermap.
225  const char *MappedName = nullptr;
226 
227  /// Default constructor -- Initialize all members with zero.
228  LookupFileCacheInfo() = default;
229 
230  void reset(unsigned StartIdx) {
231  this->StartIdx = StartIdx;
232  this->MappedName = nullptr;
233  }
234  };
235  llvm::StringMap<LookupFileCacheInfo, llvm::BumpPtrAllocator> LookupFileCache;
236 
237  /// Collection mapping a framework or subframework
238  /// name like "Carbon" to the Carbon.framework directory.
239  llvm::StringMap<FrameworkCacheEntry, llvm::BumpPtrAllocator> FrameworkMap;
240 
241  /// Maps include file names (including the quotes or
242  /// angle brackets) to other include file names. This is used to support the
243  /// include_alias pragma for Microsoft compatibility.
244  using IncludeAliasMap =
245  llvm::StringMap<std::string, llvm::BumpPtrAllocator>;
246  std::unique_ptr<IncludeAliasMap> IncludeAliases;
247 
248  /// This is a mapping from FileEntry -> HeaderMap, uniquing headermaps.
249  std::vector<std::pair<const FileEntry *, std::unique_ptr<HeaderMap>>> HeaderMaps;
250 
251  /// The mapping between modules and headers.
252  mutable ModuleMap ModMap;
253 
254  /// Describes whether a given directory has a module map in it.
255  llvm::DenseMap<const DirectoryEntry *, bool> DirectoryHasModuleMap;
256 
257  /// Set of module map files we've already loaded, and a flag indicating
258  /// whether they were valid or not.
259  llvm::DenseMap<const FileEntry *, bool> LoadedModuleMaps;
260 
261  /// Uniqued set of framework names, which is used to track which
262  /// headers were included as framework headers.
263  llvm::StringSet<llvm::BumpPtrAllocator> FrameworkNames;
264 
265  /// Entity used to resolve the identifier IDs of controlling
266  /// macros into IdentifierInfo pointers, and keep the identifire up to date,
267  /// as needed.
268  ExternalPreprocessorSource *ExternalLookup = nullptr;
269 
270  /// Entity used to look up stored header file information.
271  ExternalHeaderFileInfoSource *ExternalSource = nullptr;
272 
273 public:
274  HeaderSearch(std::shared_ptr<HeaderSearchOptions> HSOpts,
275  SourceManager &SourceMgr, DiagnosticsEngine &Diags,
276  const LangOptions &LangOpts, const TargetInfo *Target);
277  HeaderSearch(const HeaderSearch &) = delete;
278  HeaderSearch &operator=(const HeaderSearch &) = delete;
279 
280  /// Retrieve the header-search options with which this header search
281  /// was initialized.
282  HeaderSearchOptions &getHeaderSearchOpts() const { return *HSOpts; }
283 
284  FileManager &getFileMgr() const { return FileMgr; }
285 
286  DiagnosticsEngine &getDiags() const { return Diags; }
287 
288  /// Interface for setting the file search paths.
289  void SetSearchPaths(std::vector<DirectoryLookup> dirs, unsigned angledDirIdx,
290  unsigned systemDirIdx, bool noCurDirSearch,
291  llvm::DenseMap<unsigned, unsigned> searchDirToHSEntry) {
292  assert(angledDirIdx <= systemDirIdx && systemDirIdx <= dirs.size() &&
293  "Directory indices are unordered");
294  SearchDirs = std::move(dirs);
295  SearchDirsUsage.assign(SearchDirs.size(), false);
296  AngledDirIdx = angledDirIdx;
297  SystemDirIdx = systemDirIdx;
298  NoCurDirSearch = noCurDirSearch;
299  SearchDirToHSEntry = std::move(searchDirToHSEntry);
300  //LookupFileCache.clear();
301  }
302 
303  /// Add an additional search path.
304  void AddSearchPath(const DirectoryLookup &dir, bool isAngled) {
305  unsigned idx = isAngled ? SystemDirIdx : AngledDirIdx;
306  SearchDirs.insert(SearchDirs.begin() + idx, dir);
307  SearchDirsUsage.insert(SearchDirsUsage.begin() + idx, false);
308  if (!isAngled)
309  AngledDirIdx++;
310  SystemDirIdx++;
311  }
312 
313  /// Set the list of system header prefixes.
314  void SetSystemHeaderPrefixes(ArrayRef<std::pair<std::string, bool>> P) {
315  SystemHeaderPrefixes.assign(P.begin(), P.end());
316  }
317 
318  /// Checks whether the map exists or not.
319  bool HasIncludeAliasMap() const { return (bool)IncludeAliases; }
320 
321  /// Map the source include name to the dest include name.
322  ///
323  /// The Source should include the angle brackets or quotes, the dest
324  /// should not. This allows for distinction between <> and "" headers.
325  void AddIncludeAlias(StringRef Source, StringRef Dest) {
326  if (!IncludeAliases)
327  IncludeAliases.reset(new IncludeAliasMap);
328  (*IncludeAliases)[Source] = std::string(Dest);
329  }
330 
331  /// Maps one header file name to a different header
332  /// file name, for use with the include_alias pragma. Note that the source
333  /// file name should include the angle brackets or quotes. Returns StringRef
334  /// as null if the header cannot be mapped.
335  StringRef MapHeaderToIncludeAlias(StringRef Source) {
336  assert(IncludeAliases && "Trying to map headers when there's no map");
337 
338  // Do any filename replacements before anything else
339  IncludeAliasMap::const_iterator Iter = IncludeAliases->find(Source);
340  if (Iter != IncludeAliases->end())
341  return Iter->second;
342  return {};
343  }
344 
345  /// Set the hash to use for module cache paths.
346  void setModuleHash(StringRef Hash) { ModuleHash = std::string(Hash); }
347 
348  /// Set the path to the module cache.
349  void setModuleCachePath(StringRef CachePath) {
350  ModuleCachePath = std::string(CachePath);
351  }
352 
353  /// Retrieve the module hash.
354  StringRef getModuleHash() const { return ModuleHash; }
355 
356  /// Retrieve the path to the module cache.
357  StringRef getModuleCachePath() const { return ModuleCachePath; }
358 
359  /// Consider modules when including files from this directory.
361  DirectoryHasModuleMap[Dir] = true;
362  }
363 
364  /// Forget everything we know about headers so far.
365  void ClearFileInfo() {
366  FileInfo.clear();
367  }
368 
370  ExternalLookup = EPS;
371  }
372 
374  return ExternalLookup;
375  }
376 
377  /// Set the external source of header information.
379  ExternalSource = ES;
380  }
381 
382  /// Set the target information for the header search, if not
383  /// already known.
384  void setTarget(const TargetInfo &Target);
385 
386  /// Given a "foo" or <foo> reference, look up the indicated file,
387  /// return null on failure.
388  ///
389  /// \returns If successful, this returns 'UsedDir', the DirectoryLookup member
390  /// the file was found in, or null if not applicable.
391  ///
392  /// \param IncludeLoc Used for diagnostics if valid.
393  ///
394  /// \param isAngled indicates whether the file reference is a <> reference.
395  ///
396  /// \param CurDir If non-null, the file was found in the specified directory
397  /// search location. This is used to implement \#include_next.
398  ///
399  /// \param Includers Indicates where the \#including file(s) are, in case
400  /// relative searches are needed. In reverse order of inclusion.
401  ///
402  /// \param SearchPath If non-null, will be set to the search path relative
403  /// to which the file was found. If the include path is absolute, SearchPath
404  /// will be set to an empty string.
405  ///
406  /// \param RelativePath If non-null, will be set to the path relative to
407  /// SearchPath at which the file was found. This only differs from the
408  /// Filename for framework includes.
409  ///
410  /// \param SuggestedModule If non-null, and the file found is semantically
411  /// part of a known module, this will be set to the module that should
412  /// be imported instead of preprocessing/parsing the file found.
413  ///
414  /// \param IsMapped If non-null, and the search involved header maps, set to
415  /// true.
416  ///
417  /// \param IsFrameworkFound If non-null, will be set to true if a framework is
418  /// found in any of searched SearchDirs. Will be set to false if a framework
419  /// is found only through header maps. Doesn't guarantee the requested file is
420  /// found.
422  StringRef Filename, SourceLocation IncludeLoc, bool isAngled,
423  const DirectoryLookup *FromDir, const DirectoryLookup *&CurDir,
424  ArrayRef<std::pair<const FileEntry *, const DirectoryEntry *>> Includers,
425  SmallVectorImpl<char> *SearchPath, SmallVectorImpl<char> *RelativePath,
426  Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule,
427  bool *IsMapped, bool *IsFrameworkFound, bool SkipCache = false,
428  bool BuildSystemModule = false);
429 
430  /// Look up a subframework for the specified \#include file.
431  ///
432  /// For example, if \#include'ing <HIToolbox/HIToolbox.h> from
433  /// within ".../Carbon.framework/Headers/Carbon.h", check to see if
434  /// HIToolbox is a subframework within Carbon.framework. If so, return
435  /// the FileEntry for the designated file, otherwise return null.
437  StringRef Filename, const FileEntry *ContextFileEnt,
438  SmallVectorImpl<char> *SearchPath, SmallVectorImpl<char> *RelativePath,
439  Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule);
440 
441  /// Look up the specified framework name in our framework cache.
442  /// \returns The DirectoryEntry it is in if we know, null otherwise.
444  return FrameworkMap[FWName];
445  }
446 
447  /// Mark the specified file as a target of a \#include,
448  /// \#include_next, or \#import directive.
449  ///
450  /// \return false if \#including the file will have no effect or true
451  /// if we should include it.
452  bool ShouldEnterIncludeFile(Preprocessor &PP, const FileEntry *File,
453  bool isImport, bool ModulesEnabled,
454  Module *M);
455 
456  /// Return whether the specified file is a normal header,
457  /// a system header, or a C++ friendly system header.
460  }
461 
462  /// Mark the specified file as a "once only" file due to
463  /// \#pragma once.
464  void MarkFileIncludeOnce(const FileEntry *File) {
466  FI.isPragmaOnce = true;
467  }
468 
469  /// Mark the specified file as a system header, e.g. due to
470  /// \#pragma GCC system_header.
471  void MarkFileSystemHeader(const FileEntry *File) {
473  }
474 
475  void AddFileAlias(const FileEntry *File, StringRef Alias) {
476  getFileInfo(File).Aliases.insert(Alias);
477  }
478 
479  /// Mark the specified file as part of a module.
480  void MarkFileModuleHeader(const FileEntry *FE,
482  bool isCompilingModuleHeader);
483 
484  /// Increment the count for the number of times the specified
485  /// FileEntry has been entered.
486  void IncrementIncludeCount(const FileEntry *File) {
488  }
489 
490  /// Mark the specified file as having a controlling macro.
491  ///
492  /// This is used by the multiple-include optimization to eliminate
493  /// no-op \#includes.
495  const IdentifierInfo *ControllingMacro) {
496  getFileInfo(File).ControllingMacro = ControllingMacro;
497  }
498 
499  /// Return true if this is the first time encountering this header.
500  bool FirstTimeLexingFile(const FileEntry *File) {
501  return getFileInfo(File).NumIncludes == 1;
502  }
503 
504  /// Determine whether this file is intended to be safe from
505  /// multiple inclusions, e.g., it has \#pragma once or a controlling
506  /// macro.
507  ///
508  /// This routine does not consider the effect of \#import
509  bool isFileMultipleIncludeGuarded(const FileEntry *File);
510 
511  /// Determine whether the given file is known to have ever been \#imported.
512  bool hasFileBeenImported(const FileEntry *File) {
514  return FI && FI->isImport;
515  }
516 
517  /// Determine which HeaderSearchOptions::UserEntries have been successfully
518  /// used so far and mark their index with 'true' in the resulting bit vector.
519  std::vector<bool> computeUserEntryUsage() const;
520 
521  /// This method returns a HeaderMap for the specified
522  /// FileEntry, uniquing them through the 'HeaderMaps' datastructure.
523  const HeaderMap *CreateHeaderMap(const FileEntry *FE);
524 
525  /// Get filenames for all registered header maps.
527 
528  /// Retrieve the name of the cached module file that should be used
529  /// to load the given module.
530  ///
531  /// \param Module The module whose module file name will be returned.
532  ///
533  /// \returns The name of the module file that corresponds to this module,
534  /// or an empty string if this module does not correspond to any module file.
536 
537  /// Retrieve the name of the prebuilt module file that should be used
538  /// to load a module with the given name.
539  ///
540  /// \param ModuleName The module whose module file name will be returned.
541  ///
542  /// \param FileMapOnly If true, then only look in the explicit module name
543  // to file name map and skip the directory search.
544  ///
545  /// \returns The name of the module file that corresponds to this module,
546  /// or an empty string if this module does not correspond to any module file.
547  std::string getPrebuiltModuleFileName(StringRef ModuleName,
548  bool FileMapOnly = false);
549 
550  /// Retrieve the name of the prebuilt module file that should be used
551  /// to load the given module.
552  ///
553  /// \param Module The module whose module file name will be returned.
554  ///
555  /// \returns The name of the module file that corresponds to this module,
556  /// or an empty string if this module does not correspond to any module file.
558 
559  /// Retrieve the name of the (to-be-)cached module file that should
560  /// be used to load a module with the given name.
561  ///
562  /// \param ModuleName The module whose module file name will be returned.
563  ///
564  /// \param ModuleMapPath A path that when combined with \c ModuleName
565  /// uniquely identifies this module. See Module::ModuleMap.
566  ///
567  /// \returns The name of the module file that corresponds to this module,
568  /// or an empty string if this module does not correspond to any module file.
569  std::string getCachedModuleFileName(StringRef ModuleName,
570  StringRef ModuleMapPath);
571 
572  /// Lookup a module Search for a module with the given name.
573  ///
574  /// \param ModuleName The name of the module we're looking for.
575  ///
576  /// \param ImportLoc Location of the module include/import.
577  ///
578  /// \param AllowSearch Whether we are allowed to search in the various
579  /// search directories to produce a module definition. If not, this lookup
580  /// will only return an already-known module.
581  ///
582  /// \param AllowExtraModuleMapSearch Whether we allow to search modulemaps
583  /// in subdirectories.
584  ///
585  /// \returns The module with the given name.
586  Module *lookupModule(StringRef ModuleName,
587  SourceLocation ImportLoc = SourceLocation(),
588  bool AllowSearch = true,
589  bool AllowExtraModuleMapSearch = false);
590 
591  /// Try to find a module map file in the given directory, returning
592  /// \c nullptr if none is found.
593  const FileEntry *lookupModuleMapFile(const DirectoryEntry *Dir,
594  bool IsFramework);
595 
596  /// Determine whether there is a module map that may map the header
597  /// with the given file name to a (sub)module.
598  /// Always returns false if modules are disabled.
599  ///
600  /// \param Filename The name of the file.
601  ///
602  /// \param Root The "root" directory, at which we should stop looking for
603  /// module maps.
604  ///
605  /// \param IsSystem Whether the directories we're looking at are system
606  /// header directories.
607  bool hasModuleMap(StringRef Filename, const DirectoryEntry *Root,
608  bool IsSystem);
609 
610  /// Retrieve the module that corresponds to the given file, if any.
611  ///
612  /// \param File The header that we wish to map to a module.
613  /// \param AllowTextual Whether we want to find textual headers too.
615  bool AllowTextual = false) const;
616 
617  /// Retrieve all the modules corresponding to the given file.
618  ///
619  /// \ref findModuleForHeader should typically be used instead of this.
621  findAllModulesForHeader(const FileEntry *File) const;
622 
623  /// Read the contents of the given module map file.
624  ///
625  /// \param File The module map file.
626  /// \param IsSystem Whether this file is in a system header directory.
627  /// \param ID If the module map file is already mapped (perhaps as part of
628  /// processing a preprocessed module), the ID of the file.
629  /// \param Offset [inout] An offset within ID to start parsing. On exit,
630  /// filled by the end of the parsed contents (either EOF or the
631  /// location of an end-of-module-map pragma).
632  /// \param OriginalModuleMapFile The original path to the module map file,
633  /// used to resolve paths within the module (this is required when
634  /// building the module from preprocessed source).
635  /// \returns true if an error occurred, false otherwise.
636  bool loadModuleMapFile(const FileEntry *File, bool IsSystem,
637  FileID ID = FileID(), unsigned *Offset = nullptr,
638  StringRef OriginalModuleMapFile = StringRef());
639 
640  /// Collect the set of all known, top-level modules.
641  ///
642  /// \param Modules Will be filled with the set of known, top-level modules.
644 
645  /// Load all known, top-level system modules.
647 
648 private:
649  /// Lookup a module with the given module name and search-name.
650  ///
651  /// \param ModuleName The name of the module we're looking for.
652  ///
653  /// \param SearchName The "search-name" to derive filesystem paths from
654  /// when looking for the module map; this is usually equal to ModuleName,
655  /// but for compatibility with some buggy frameworks, additional attempts
656  /// may be made to find the module under a related-but-different search-name.
657  ///
658  /// \param ImportLoc Location of the module include/import.
659  ///
660  /// \param AllowExtraModuleMapSearch Whether we allow to search modulemaps
661  /// in subdirectories.
662  ///
663  /// \returns The module named ModuleName.
664  Module *lookupModule(StringRef ModuleName, StringRef SearchName,
665  SourceLocation ImportLoc,
666  bool AllowExtraModuleMapSearch = false);
667 
668  /// Retrieve the name of the (to-be-)cached module file that should
669  /// be used to load a module with the given name.
670  ///
671  /// \param ModuleName The module whose module file name will be returned.
672  ///
673  /// \param ModuleMapPath A path that when combined with \c ModuleName
674  /// uniquely identifies this module. See Module::ModuleMap.
675  ///
676  /// \param CachePath A path to the module cache.
677  ///
678  /// \returns The name of the module file that corresponds to this module,
679  /// or an empty string if this module does not correspond to any module file.
680  std::string getCachedModuleFileNameImpl(StringRef ModuleName,
681  StringRef ModuleMapPath,
682  StringRef CachePath);
683 
684  /// Retrieve a module with the given name, which may be part of the
685  /// given framework.
686  ///
687  /// \param Name The name of the module to retrieve.
688  ///
689  /// \param Dir The framework directory (e.g., ModuleName.framework).
690  ///
691  /// \param IsSystem Whether the framework directory is part of the system
692  /// frameworks.
693  ///
694  /// \returns The module, if found; otherwise, null.
695  Module *loadFrameworkModule(StringRef Name,
696  const DirectoryEntry *Dir,
697  bool IsSystem);
698 
699  /// Load all of the module maps within the immediate subdirectories
700  /// of the given search directory.
701  void loadSubdirectoryModuleMaps(DirectoryLookup &SearchDir);
702 
703  /// Find and suggest a usable module for the given file.
704  ///
705  /// \return \c true if the file can be used, \c false if we are not permitted to
706  /// find this file due to requirements from \p RequestingModule.
707  bool findUsableModuleForHeader(const FileEntry *File,
708  const DirectoryEntry *Root,
709  Module *RequestingModule,
710  ModuleMap::KnownHeader *SuggestedModule,
711  bool IsSystemHeaderDir);
712 
713  /// Find and suggest a usable module for the given file, which is part of
714  /// the specified framework.
715  ///
716  /// \return \c true if the file can be used, \c false if we are not permitted to
717  /// find this file due to requirements from \p RequestingModule.
718  bool findUsableModuleForFrameworkHeader(
719  const FileEntry *File, StringRef FrameworkName, Module *RequestingModule,
720  ModuleMap::KnownHeader *SuggestedModule, bool IsSystemFramework);
721 
722  /// Look up the file with the specified name and determine its owning
723  /// module.
725  getFileAndSuggestModule(StringRef FileName, SourceLocation IncludeLoc,
726  const DirectoryEntry *Dir, bool IsSystemHeaderDir,
727  Module *RequestingModule,
728  ModuleMap::KnownHeader *SuggestedModule);
729 
730  /// Cache the result of a successful lookup at the given include location
731  /// using the search path at index `HitIdx`.
732  void cacheLookupSuccess(LookupFileCacheInfo &CacheLookup, unsigned HitIdx,
733  SourceLocation IncludeLoc);
734  /// Note that a lookup at the given include location was successful using the
735  /// search path at index `HitIdx`.
736  void noteLookupUsage(unsigned HitIdx, SourceLocation IncludeLoc);
737 
738 public:
739  /// Retrieve the module map.
740  ModuleMap &getModuleMap() { return ModMap; }
741 
742  /// Retrieve the module map.
743  const ModuleMap &getModuleMap() const { return ModMap; }
744 
745  unsigned header_file_size() const { return FileInfo.size(); }
746 
747  /// Return the HeaderFileInfo structure for the specified FileEntry,
748  /// in preparation for updating it in some way.
750 
751  /// Return the HeaderFileInfo structure for the specified FileEntry,
752  /// if it has ever been filled in.
753  /// \param WantExternal Whether the caller wants purely-external header file
754  /// info (where \p External is true).
756  bool WantExternal = true) const;
757 
758  // Used by external tools
759  using search_dir_iterator = std::vector<DirectoryLookup>::const_iterator;
760 
761  search_dir_iterator search_dir_begin() const { return SearchDirs.begin(); }
762  search_dir_iterator search_dir_end() const { return SearchDirs.end(); }
763  unsigned search_dir_size() const { return SearchDirs.size(); }
764 
766  return SearchDirs.begin();
767  }
768 
770  return SearchDirs.begin() + AngledDirIdx;
771  }
772 
774  return SearchDirs.begin() + AngledDirIdx;
775  }
776 
778  return SearchDirs.begin() + SystemDirIdx;
779  }
780 
782  return SearchDirs.begin() + SystemDirIdx;
783  }
784 
785  search_dir_iterator system_dir_end() const { return SearchDirs.end(); }
786 
787  /// Get the index of the given search directory.
789 
790  /// Retrieve a uniqued framework name.
791  StringRef getUniqueFrameworkName(StringRef Framework);
792 
793  /// Suggest a path by which the specified file could be found, for use in
794  /// diagnostics to suggest a #include. Returned path will only contain forward
795  /// slashes as separators. MainFile is the absolute path of the file that we
796  /// are generating the diagnostics for. It will try to shorten the path using
797  /// MainFile location, if none of the include search directories were prefix
798  /// of File.
799  ///
800  /// \param IsSystem If non-null, filled in to indicate whether the suggested
801  /// path is relative to a system header directory.
803  llvm::StringRef MainFile,
804  bool *IsSystem = nullptr);
805 
806  /// Suggest a path by which the specified file could be found, for use in
807  /// diagnostics to suggest a #include. Returned path will only contain forward
808  /// slashes as separators. MainFile is the absolute path of the file that we
809  /// are generating the diagnostics for. It will try to shorten the path using
810  /// MainFile location, if none of the include search directories were prefix
811  /// of File.
812  ///
813  /// \param WorkingDir If non-empty, this will be prepended to search directory
814  /// paths that are relative.
815  std::string suggestPathToFileForDiagnostics(llvm::StringRef File,
816  llvm::StringRef WorkingDir,
817  llvm::StringRef MainFile,
818  bool *IsSystem = nullptr);
819 
820  void PrintStats();
821 
822  size_t getTotalMemory() const;
823 
824 private:
825  /// Describes what happened when we tried to load a module map file.
826  enum LoadModuleMapResult {
827  /// The module map file had already been loaded.
828  LMM_AlreadyLoaded,
829 
830  /// The module map file was loaded by this invocation.
831  LMM_NewlyLoaded,
832 
833  /// There is was directory with the given name.
834  LMM_NoDirectory,
835 
836  /// There was either no module map file or the module map file was
837  /// invalid.
838  LMM_InvalidModuleMap
839  };
840 
841  LoadModuleMapResult loadModuleMapFileImpl(const FileEntry *File,
842  bool IsSystem,
843  const DirectoryEntry *Dir,
844  FileID ID = FileID(),
845  unsigned *Offset = nullptr);
846 
847  /// Try to load the module map file in the given directory.
848  ///
849  /// \param DirName The name of the directory where we will look for a module
850  /// map file.
851  /// \param IsSystem Whether this is a system header directory.
852  /// \param IsFramework Whether this is a framework directory.
853  ///
854  /// \returns The result of attempting to load the module map file from the
855  /// named directory.
856  LoadModuleMapResult loadModuleMapFile(StringRef DirName, bool IsSystem,
857  bool IsFramework);
858 
859  /// Try to load the module map file in the given directory.
860  ///
861  /// \param Dir The directory where we will look for a module map file.
862  /// \param IsSystem Whether this is a system header directory.
863  /// \param IsFramework Whether this is a framework directory.
864  ///
865  /// \returns The result of attempting to load the module map file from the
866  /// named directory.
867  LoadModuleMapResult loadModuleMapFile(const DirectoryEntry *Dir,
868  bool IsSystem, bool IsFramework);
869 };
870 
871 } // namespace clang
872 
873 #endif // LLVM_CLANG_LEX_HEADERSEARCH_H
clang::HeaderSearch::AddSearchPath
void AddSearchPath(const DirectoryLookup &dir, bool isAngled)
Add an additional search path.
Definition: HeaderSearch.h:304
clang::HeaderSearch::isFileMultipleIncludeGuarded
bool isFileMultipleIncludeGuarded(const FileEntry *File)
Determine whether this file is intended to be safe from multiple inclusions, e.g.,...
Definition: HeaderSearch.cpp:1282
clang::HeaderSearch::operator=
HeaderSearch & operator=(const HeaderSearch &)=delete
clang::ExternalHeaderFileInfoSource::GetHeaderFileInfo
virtual HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE)=0
Retrieve the header file information for the given file entry.
clang::HeaderSearch::system_dir_end
search_dir_iterator system_dir_end() const
Definition: HeaderSearch.h:785
clang::HeaderFileInfo::IsValid
unsigned IsValid
Whether this file has been looked up as a header.
Definition: HeaderSearch.h:90
clang::HeaderSearch::getFileInfo
HeaderFileInfo & getFileInfo(const FileEntry *FE)
Return the HeaderFileInfo structure for the specified FileEntry, in preparation for updating it in so...
Definition: HeaderSearch.cpp:1224
clang::HeaderSearch::search_dir_size
unsigned search_dir_size() const
Definition: HeaderSearch.h:763
clang::ExternalPreprocessorSource
Abstract interface for external sources of preprocessor information.
Definition: ExternalPreprocessorSource.h:26
clang::HeaderFileInfo::Framework
StringRef Framework
If this header came from a framework include, this is the name of the framework.
Definition: HeaderSearch.h:114
clang::ModuleMap::KnownHeader
A header that is known to reside within a given module, whether it was included or excluded.
Definition: ModuleMap.h:155
clang::HeaderFileInfo::isPragmaOnce
unsigned isPragmaOnce
True if this is a #pragma once file.
Definition: HeaderSearch.h:58
clang::HeaderSearch::getDiags
DiagnosticsEngine & getDiags() const
Definition: HeaderSearch.h:286
clang::DeclaratorContext::File
@ File
clang::HeaderSearch::HasIncludeAliasMap
bool HasIncludeAliasMap() const
Checks whether the map exists or not.
Definition: HeaderSearch.h:319
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::HeaderSearch::search_dir_iterator
std::vector< DirectoryLookup >::const_iterator search_dir_iterator
Definition: HeaderSearch.h:759
ModuleMap.h
clang::HeaderSearch::getFileDirFlavor
SrcMgr::CharacteristicKind getFileDirFlavor(const FileEntry *File)
Return whether the specified file is a normal header, a system header, or a C++ friendly system heade...
Definition: HeaderSearch.h:458
clang::HeaderSearch::AddFileAlias
void AddFileAlias(const FileEntry *File, StringRef Alias)
Definition: HeaderSearch.h:475
llvm::SmallVector
Definition: LLVM.h:38
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:88
clang::HeaderSearch::hasModuleMap
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...
Definition: HeaderSearch.cpp:1412
clang::HeaderSearch::angled_dir_begin
search_dir_iterator angled_dir_begin() const
Definition: HeaderSearch.h:773
clang::FrameworkCacheEntry::IsUserSpecifiedSystemFramework
bool IsUserSpecifiedSystemFramework
Whether this framework has been "user-specified" to be treated as if it were a system framework (even...
Definition: HeaderSearch.h:164
clang::HeaderSearch::computeUserEntryUsage
std::vector< bool > computeUserEntryUsage() const
Determine which HeaderSearchOptions::UserEntries have been successfully used so far and mark their in...
Definition: HeaderSearch.cpp:111
clang::HeaderSearch::LookupFrameworkCache
FrameworkCacheEntry & LookupFrameworkCache(StringRef FWName)
Look up the specified framework name in our framework cache.
Definition: HeaderSearch.h:443
Filename
StringRef Filename
Definition: Format.cpp:2333
clang::DiagnosticsEngine
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:191
clang::TargetInfo
Exposes information about the current target.
Definition: TargetInfo.h:189
clang::HeaderFileInfo::ControllingMacro
const IdentifierInfo * ControllingMacro
If this file has a #ifndef XXX (or equivalent) guard that protects the entire contents of the file,...
Definition: HeaderSearch.h:110
clang::HeaderSearch::SetFileControllingMacro
void SetFileControllingMacro(const FileEntry *File, const IdentifierInfo *ControllingMacro)
Mark the specified file as having a controlling macro.
Definition: HeaderSearch.h:494
clang::HeaderFileInfo::External
unsigned External
Whether this header file info was supplied by an external source, and has not changed since.
Definition: HeaderSearch.h:68
llvm::Optional< FileEntryRef >
SourceManager.h
clang::SrcMgr::CharacteristicKind
CharacteristicKind
Indicates whether a file or directory holds normal user code, system code, or system code which is im...
Definition: SourceManager.h:78
clang::HeaderSearch::search_dir_begin
search_dir_iterator search_dir_begin() const
Definition: HeaderSearch.h:761
clang::HeaderFileInfo::getControllingMacro
const IdentifierInfo * getControllingMacro(ExternalPreprocessorSource *External)
Retrieve the controlling macro for this header file, if any.
Definition: HeaderSearch.cpp:61
DirectoryLookup.h
clang::HeaderSearch
Encapsulates the information needed to find the file referenced by a #include or #include_next,...
Definition: HeaderSearch.h:169
clang::HeaderSearch::getExternalLookup
ExternalPreprocessorSource * getExternalLookup() const
Definition: HeaderSearch.h:373
Offset
unsigned Offset
Definition: Format.cpp:2335
clang::HeaderSearch::MarkFileIncludeOnce
void MarkFileIncludeOnce(const FileEntry *File)
Mark the specified file as a "once only" file due to #pragma once.
Definition: HeaderSearch.h:464
clang::HeaderSearch::getUniqueFrameworkName
StringRef getUniqueFrameworkName(StringRef Framework)
Retrieve a uniqued framework name.
Definition: HeaderSearch.cpp:1408
clang::HeaderFileInfo::Aliases
llvm::SetVector< llvm::SmallString< 32 >, llvm::SmallVector< llvm::SmallString< 32 >, 2 >, llvm::SmallSet< llvm::SmallString< 32 >, 2 > > Aliases
List of aliases that this header is known as.
Definition: HeaderSearch.h:122
clang::ModuleMap::ModuleHeaderRole
ModuleHeaderRole
Flags describing the role of a module header.
Definition: ModuleMap.h:128
clang::HeaderSearch::collectAllModules
void collectAllModules(SmallVectorImpl< Module * > &Modules)
Collect the set of all known, top-level modules.
Definition: HeaderSearch.cpp:1729
clang::HeaderFileInfo::Resolved
unsigned Resolved
Whether this structure is considered to already have been "resolved", meaning that it was loaded from...
Definition: HeaderSearch.h:78
clang::HeaderSearch::setModuleHash
void setModuleHash(StringRef Hash)
Set the hash to use for module cache paths.
Definition: HeaderSearch.h:346
clang::HeaderSearch::ShouldEnterIncludeFile
bool ShouldEnterIncludeFile(Preprocessor &PP, const FileEntry *File, bool isImport, bool ModulesEnabled, Module *M)
Mark the specified file as a target of a #include, #include_next, or #import directive.
Definition: HeaderSearch.cpp:1311
clang::Module
Describes a module or submodule.
Definition: Module.h:96
clang::ExternalHeaderFileInfoSource
An external source of header file information, which may supply information about header files alread...
Definition: HeaderSearch.h:144
clang::HeaderFileInfo::HeaderFileInfo
HeaderFileInfo()
Definition: HeaderSearch.h:124
clang::DirectoryEntry
Cached information about one directory (either on disk or in the virtual file system).
Definition: DirectoryEntry.h:33
clang::HeaderSearch::getFileMgr
FileManager & getFileMgr() const
Definition: HeaderSearch.h:284
clang::index::SymbolKind::Module
@ Module
clang::HeaderSearch::loadModuleMapFile
bool loadModuleMapFile(const FileEntry *File, bool IsSystem, FileID ID=FileID(), unsigned *Offset=nullptr, StringRef OriginalModuleMapFile=StringRef())
Read the contents of the given module map file.
Definition: HeaderSearch.cpp:1565
clang::HeaderSearch::getExistingFileInfo
const HeaderFileInfo * getExistingFileInfo(const FileEntry *FE, bool WantExternal=true) const
Return the HeaderFileInfo structure for the specified FileEntry, if it has ever been filled in.
Definition: HeaderSearch.cpp:1247
clang::HeaderFileInfo::IndexHeaderMapHeader
unsigned IndexHeaderMapHeader
Whether this is a header inside a framework that is currently being built.
Definition: HeaderSearch.h:87
clang::HeaderSearch::findAllModulesForHeader
ArrayRef< ModuleMap::KnownHeader > findAllModulesForHeader(const FileEntry *File) const
Retrieve all the modules corresponding to the given file.
Definition: HeaderSearch.cpp:1471
clang::DirectoryLookup
DirectoryLookup - This class represents one entry in the search list that specifies the search order ...
Definition: DirectoryLookup.h:30
clang::FrameworkCacheEntry::Directory
const DirectoryEntry * Directory
The directory entry which should be used for the cached framework.
Definition: HeaderSearch.h:159
clang::ExternalHeaderFileInfoSource::~ExternalHeaderFileInfoSource
virtual ~ExternalHeaderFileInfoSource()
clang::HeaderSearch::lookupModule
Module * lookupModule(StringRef ModuleName, SourceLocation ImportLoc=SourceLocation(), bool AllowSearch=true, bool AllowExtraModuleMapSearch=false)
Lookup a module Search for a module with the given name.
Definition: HeaderSearch.cpp:246
clang::HeaderSearch::suggestPathToFileForDiagnostics
std::string suggestPathToFileForDiagnostics(const FileEntry *File, llvm::StringRef MainFile, bool *IsSystem=nullptr)
Suggest a path by which the specified file could be found, for use in diagnostics to suggest a includ...
Definition: HeaderSearch.cpp:1826
clang::FrameworkCacheEntry
This structure is used to record entries in our framework cache.
Definition: HeaderSearch.h:157
clang::HeaderSearch::LookupFile
Optional< FileEntryRef > LookupFile(StringRef Filename, SourceLocation IncludeLoc, bool isAngled, const DirectoryLookup *FromDir, const DirectoryLookup *&CurDir, ArrayRef< std::pair< const FileEntry *, const DirectoryEntry * >> Includers, SmallVectorImpl< char > *SearchPath, SmallVectorImpl< char > *RelativePath, Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule, bool *IsMapped, bool *IsFrameworkFound, bool SkipCache=false, bool BuildSystemModule=false)
Given a "foo" or <foo> reference, look up the indicated file, return null on failure.
Definition: HeaderSearch.cpp:795
clang::HeaderSearch::FirstTimeLexingFile
bool FirstTimeLexingFile(const FileEntry *File)
Return true if this is the first time encountering this header.
Definition: HeaderSearch.h:500
clang::HeaderSearch::quoted_dir_begin
search_dir_iterator quoted_dir_begin() const
Definition: HeaderSearch.h:765
clang::HeaderSearch::getModuleHash
StringRef getModuleHash() const
Retrieve the module hash.
Definition: HeaderSearch.h:354
clang::SrcMgr::C_User
@ C_User
Definition: SourceManager.h:79
clang::HeaderSearch::SetSystemHeaderPrefixes
void SetSystemHeaderPrefixes(ArrayRef< std::pair< std::string, bool >> P)
Set the list of system header prefixes.
Definition: HeaderSearch.h:314
clang::HeaderSearch::MapHeaderToIncludeAlias
StringRef MapHeaderToIncludeAlias(StringRef Source)
Maps one header file name to a different header file name, for use with the include_alias pragma.
Definition: HeaderSearch.h:335
clang::HeaderMap
This class represents an Apple concept known as a 'header map'.
Definition: HeaderMap.h:70
clang::HeaderFileInfo::isNonDefault
bool isNonDefault() const
Determine whether this is a non-default header file info, e.g., it corresponds to an actual header we...
Definition: HeaderSearch.h:136
clang::HeaderSearch::SetSearchPaths
void SetSearchPaths(std::vector< DirectoryLookup > dirs, unsigned angledDirIdx, unsigned systemDirIdx, bool noCurDirSearch, llvm::DenseMap< unsigned, unsigned > searchDirToHSEntry)
Interface for setting the file search paths.
Definition: HeaderSearch.h:289
clang::FileEntry
Cached information about one file (either on disk or in the virtual file system).
Definition: FileEntry.h:331
clang::ModuleMap
Definition: ModuleMap.h:75
clang::HeaderSearch::MarkFileModuleHeader
void MarkFileModuleHeader(const FileEntry *FE, ModuleMap::ModuleHeaderRole Role, bool isCompilingModuleHeader)
Mark the specified file as part of a module.
Definition: HeaderSearch.cpp:1292
clang::HeaderSearch::CreateHeaderMap
const HeaderMap * CreateHeaderMap(const FileEntry *FE)
This method returns a HeaderMap for the specified FileEntry, uniquing them through the 'HeaderMaps' d...
Definition: HeaderSearch.cpp:127
clang::HeaderSearch::getCachedModuleFileName
std::string getCachedModuleFileName(Module *Module)
Retrieve the name of the cached module file that should be used to load the given module.
Definition: HeaderSearch.cpp:153
clang::HeaderSearch::SetExternalLookup
void SetExternalLookup(ExternalPreprocessorSource *EPS)
Definition: HeaderSearch.h:369
SourceLocation.h
P
StringRef P
Definition: ASTMatchersInternal.cpp:563
clang::HeaderSearch::lookupModuleMapFile
const FileEntry * lookupModuleMapFile(const DirectoryEntry *Dir, bool IsFramework)
Try to find a module map file in the given directory, returning nullptr if none is found.
Definition: HeaderSearch.cpp:1643
clang::HeaderSearch::LookupSubframeworkHeader
Optional< FileEntryRef > LookupSubframeworkHeader(StringRef Filename, const FileEntry *ContextFileEnt, SmallVectorImpl< char > *SearchPath, SmallVectorImpl< char > *RelativePath, Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule)
Look up a subframework for the specified #include file.
Definition: HeaderSearch.cpp:1085
HeaderMap.h
false
#define false
Definition: stdbool.h:17
clang::HeaderSearch::findModuleForHeader
ModuleMap::KnownHeader findModuleForHeader(const FileEntry *File, bool AllowTextual=false) const
Retrieve the module that corresponds to the given file, if any.
Definition: HeaderSearch.cpp:1460
clang::HeaderFileInfo::NumIncludes
unsigned short NumIncludes
The number of times the file has been included already.
Definition: HeaderSearch.h:93
clang::HeaderSearch::angled_dir_end
search_dir_iterator angled_dir_end() const
Definition: HeaderSearch.h:777
clang::HeaderSearch::getModuleCachePath
StringRef getModuleCachePath() const
Retrieve the path to the module cache.
Definition: HeaderSearch.h:357
clang::HeaderSearch::IncrementIncludeCount
void IncrementIncludeCount(const FileEntry *File)
Increment the count for the number of times the specified FileEntry has been entered.
Definition: HeaderSearch.h:486
llvm::ArrayRef
Definition: LLVM.h:34
clang::HeaderSearch::SetExternalSource
void SetExternalSource(ExternalHeaderFileInfoSource *ES)
Set the external source of header information.
Definition: HeaderSearch.h:378
clang::HeaderSearch::getModuleMap
const ModuleMap & getModuleMap() const
Retrieve the module map.
Definition: HeaderSearch.h:743
clang::HeaderFileInfo::isModuleHeader
unsigned isModuleHeader
Whether this header is part of a module.
Definition: HeaderSearch.h:71
clang::HeaderSearch::searchDirIdx
Optional< unsigned > searchDirIdx(const DirectoryLookup &DL) const
Get the index of the given search directory.
Definition: HeaderSearch.cpp:1401
clang::HeaderSearch::hasFileBeenImported
bool hasFileBeenImported(const FileEntry *File)
Determine whether the given file is known to have ever been #imported.
Definition: HeaderSearch.h:512
clang::HeaderFileInfo
The preprocessor keeps track of this information for each file that is #included.
Definition: HeaderSearch.h:53
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:84
clang::HeaderSearch::loadTopLevelSystemModules
void loadTopLevelSystemModules()
Load all known, top-level system modules.
Definition: HeaderSearch.cpp:1784
clang::HeaderSearch::search_dir_end
search_dir_iterator search_dir_end() const
Definition: HeaderSearch.h:762
clang::HeaderSearch::getHeaderSearchOpts
HeaderSearchOptions & getHeaderSearchOpts() const
Retrieve the header-search options with which this header search was initialized.
Definition: HeaderSearch.h:282
clang::HeaderSearch::system_dir_begin
search_dir_iterator system_dir_begin() const
Definition: HeaderSearch.h:781
clang::HeaderSearch::MarkFileSystemHeader
void MarkFileSystemHeader(const FileEntry *File)
Mark the specified file as a system header, e.g.
Definition: HeaderSearch.h:471
clang::Builtin::ID
ID
Definition: Builtins.h:48
clang
Definition: CalledOnceCheck.h:17
clang::FileManager
Implements support for file system lookup, file system caching, and directory search management.
Definition: FileManager.h:53
clang::HeaderSearch::setModuleCachePath
void setModuleCachePath(StringRef CachePath)
Set the path to the module cache.
Definition: HeaderSearch.h:349
clang::FileID
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Definition: SourceLocation.h:40
clang::HeaderSearch::getTotalMemory
size_t getTotalMemory() const
Definition: HeaderSearch.cpp:1393
clang::HeaderSearch::header_file_size
unsigned header_file_size() const
Definition: HeaderSearch.h:745
clang::HeaderSearch::ClearFileInfo
void ClearFileInfo()
Forget everything we know about headers so far.
Definition: HeaderSearch.h:365
clang::HeaderSearch::AddIncludeAlias
void AddIncludeAlias(StringRef Source, StringRef Dest)
Map the source include name to the dest include name.
Definition: HeaderSearch.h:325
clang::HeaderSearch::getPrebuiltModuleFileName
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...
Definition: HeaderSearch.cpp:159
clang::HeaderSearch::setDirectoryHasModuleMap
void setDirectoryHasModuleMap(const DirectoryEntry *Dir)
Consider modules when including files from this directory.
Definition: HeaderSearch.h:360
clang::HeaderFileInfo::DirInfo
unsigned DirInfo
Keep track of whether this is a system header, and if so, whether it is C++ clean or not.
Definition: HeaderSearch.h:64
clang::HeaderSearch::getPrebuiltImplicitModuleFileName
std::string getPrebuiltImplicitModuleFileName(Module *Module)
Retrieve the name of the prebuilt module file that should be used to load the given module.
Definition: HeaderSearch.cpp:181
clang::HeaderSearch::HeaderSearch
HeaderSearch(std::shared_ptr< HeaderSearchOptions > HSOpts, SourceManager &SourceMgr, DiagnosticsEngine &Diags, const LangOptions &LangOpts, const TargetInfo *Target)
Definition: HeaderSearch.cpp:81
clang::HeaderSearch::getHeaderMapFileNames
void getHeaderMapFileNames(SmallVectorImpl< std::string > &Names) const
Get filenames for all registered header maps.
Definition: HeaderSearch.cpp:147
clang::HeaderFileInfo::isImport
unsigned isImport
True if this is a #import'd file.
Definition: HeaderSearch.h:55
llvm::SmallVectorImpl< char >
clang::SrcMgr::C_System
@ C_System
Definition: SourceManager.h:80
clang::Preprocessor
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:130
clang::HeaderFileInfo::ControllingMacroID
unsigned ControllingMacroID
The ID number of the controlling macro.
Definition: HeaderSearch.h:100
clang::HeaderSearch::getModuleMap
ModuleMap & getModuleMap()
Retrieve the module map.
Definition: HeaderSearch.h:740
clang::HeaderSearch::setTarget
void setTarget(const TargetInfo &Target)
Set the target information for the header search, if not already known.
Definition: HeaderSearch.cpp:693
clang::HeaderSearch::PrintStats
void PrintStats()
Definition: HeaderSearch.cpp:89
clang::HeaderFileInfo::isCompilingModuleHeader
unsigned isCompilingModuleHeader
Whether this header is part of the module that we are building.
Definition: HeaderSearch.h:74
clang::HeaderSearchOptions
HeaderSearchOptions - Helper class for storing options related to the initialization of the HeaderSea...
Definition: HeaderSearchOptions.h:68
clang::HeaderSearch::quoted_dir_end
search_dir_iterator quoted_dir_end() const
Definition: HeaderSearch.h:769