clang  12.0.0git
Module.h
Go to the documentation of this file.
1 //===- Module.h - Describe a module -----------------------------*- 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 /// \file
10 /// Defines the clang::Module class, which describes a module in the
11 /// source code.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_BASIC_MODULE_H
16 #define LLVM_CLANG_BASIC_MODULE_H
17 
19 #include "llvm/ADT/ArrayRef.h"
20 #include "llvm/ADT/DenseSet.h"
21 #include "llvm/ADT/Optional.h"
22 #include "llvm/ADT/PointerIntPair.h"
23 #include "llvm/ADT/STLExtras.h"
24 #include "llvm/ADT/SetVector.h"
25 #include "llvm/ADT/SmallVector.h"
26 #include "llvm/ADT/StringMap.h"
27 #include "llvm/ADT/StringRef.h"
28 #include "llvm/ADT/iterator_range.h"
29 #include <array>
30 #include <cassert>
31 #include <cstdint>
32 #include <ctime>
33 #include <iterator>
34 #include <string>
35 #include <utility>
36 #include <vector>
37 
38 namespace llvm {
39 
40 class raw_ostream;
41 
42 } // namespace llvm
43 
44 namespace clang {
45 
46 class DirectoryEntry;
47 class FileEntry;
48 class FileManager;
49 class LangOptions;
50 class TargetInfo;
51 
52 /// Describes the name of a module.
54 
55 /// The signature of a module, which is a hash of the AST content.
56 struct ASTFileSignature : std::array<uint8_t, 20> {
57  using BaseT = std::array<uint8_t, 20>;
58 
59  static constexpr size_t size = std::tuple_size<BaseT>::value;
60 
61  ASTFileSignature(BaseT S = {{0}}) : BaseT(std::move(S)) {}
62 
63  explicit operator bool() const { return *this != BaseT({{0}}); }
64 
65  static ASTFileSignature create(StringRef Bytes) {
66  return create(Bytes.bytes_begin(), Bytes.bytes_end());
67  }
68 
70  ASTFileSignature Sentinel;
71  Sentinel.fill(0xFF);
72  return Sentinel;
73  }
74 
75  template <typename InputIt>
76  static ASTFileSignature create(InputIt First, InputIt Last) {
77  assert(std::distance(First, Last) == size &&
78  "Wrong amount of bytes to create an ASTFileSignature");
79 
80  ASTFileSignature Signature;
81  std::copy(First, Last, Signature.begin());
82  return Signature;
83  }
84 };
85 
86 /// Describes a module or submodule.
87 class Module {
88 public:
89  /// The name of this module.
90  std::string Name;
91 
92  /// The location of the module definition.
94 
95  enum ModuleKind {
96  /// This is a module that was defined by a module map and built out
97  /// of header files.
99 
100  /// This is a C++ Modules TS module interface unit.
102 
103  /// This is a fragment of the global module within some C++ module.
105 
106  /// This is the private module fragment within some C++ module.
108  };
109 
110  /// The kind of this module.
111  ModuleKind Kind = ModuleMapModule;
112 
113  /// The parent of this module. This will be NULL for the top-level
114  /// module.
116 
117  /// The build directory of this module. This is the directory in
118  /// which the module is notionally built, and relative to which its headers
119  /// are found.
120  const DirectoryEntry *Directory = nullptr;
121 
122  /// The presumed file name for the module map defining this module.
123  /// Only non-empty when building from preprocessed source.
125 
126  /// The umbrella header or directory.
127  const void *Umbrella = nullptr;
128 
129  /// The module signature.
131 
132  /// The name of the umbrella entry, as written in the module map.
133  std::string UmbrellaAsWritten;
134 
135  /// The module through which entities defined in this module will
136  /// eventually be exposed, for use in "private" modules.
137  std::string ExportAsModule;
138 
139  /// Does this Module scope describe part of the purview of a named C++ module?
140  bool isModulePurview() const {
141  return Kind == ModuleInterfaceUnit || Kind == PrivateModuleFragment;
142  }
143 
144 private:
145  /// The submodules of this module, indexed by name.
146  std::vector<Module *> SubModules;
147 
148  /// A mapping from the submodule name to the index into the
149  /// \c SubModules vector at which that submodule resides.
150  llvm::StringMap<unsigned> SubModuleIndex;
151 
152  /// The AST file if this is a top-level module which has a
153  /// corresponding serialized AST file, or null otherwise.
154  const FileEntry *ASTFile = nullptr;
155 
156  /// The top-level headers associated with this module.
158 
159  /// top-level header filenames that aren't resolved to FileEntries yet.
160  std::vector<std::string> TopHeaderNames;
161 
162  /// Cache of modules visible to lookup in this module.
163  mutable llvm::DenseSet<const Module*> VisibleModulesCache;
164 
165  /// The ID used when referencing this module within a VisibleModuleSet.
166  unsigned VisibilityID;
167 
168 public:
169  enum HeaderKind {
174  HK_Excluded
175  };
176  static const int NumHeaderKinds = HK_Excluded + 1;
177 
178  /// Information about a header directive as found in the module map
179  /// file.
180  struct Header {
181  std::string NameAsWritten;
182  const FileEntry *Entry;
183 
184  explicit operator bool() { return Entry; }
185  };
186 
187  /// Information about a directory name as found in the module map
188  /// file.
189  struct DirectoryName {
190  std::string NameAsWritten;
192 
193  explicit operator bool() { return Entry; }
194  };
195 
196  /// The headers that are part of this module.
198 
199  /// Stored information about a header directive that was found in the
200  /// module map file but has not been resolved to a file.
202  HeaderKind Kind = HK_Normal;
204  std::string FileName;
205  bool IsUmbrella = false;
206  bool HasBuiltinHeader = false;
209  };
210 
211  /// Headers that are mentioned in the module map file but that we have not
212  /// yet attempted to resolve to a file on the file system.
214 
215  /// Headers that are mentioned in the module map file but could not be
216  /// found on the file system.
218 
219  /// An individual requirement: a feature name and a flag indicating
220  /// the required state of that feature.
221  using Requirement = std::pair<std::string, bool>;
222 
223  /// The set of language features required to use this module.
224  ///
225  /// If any of these requirements are not available, the \c IsAvailable bit
226  /// will be false to indicate that this (sub)module is not available.
228 
229  /// A module with the same name that shadows this module.
230  Module *ShadowingModule = nullptr;
231 
232  /// Whether this module has declared itself unimportable, either because
233  /// it's missing a requirement from \p Requirements or because it's been
234  /// shadowed by another module.
235  unsigned IsUnimportable : 1;
236 
237  /// Whether we tried and failed to load a module file for this module.
239 
240  /// Whether this module is available in the current translation unit.
241  ///
242  /// If the module is missing headers or does not meet all requirements then
243  /// this bit will be 0.
244  unsigned IsAvailable : 1;
245 
246  /// Whether this module was loaded from a module file.
247  unsigned IsFromModuleFile : 1;
248 
249  /// Whether this is a framework module.
250  unsigned IsFramework : 1;
251 
252  /// Whether this is an explicit submodule.
253  unsigned IsExplicit : 1;
254 
255  /// Whether this is a "system" module (which assumes that all
256  /// headers in it are system headers).
257  unsigned IsSystem : 1;
258 
259  /// Whether this is an 'extern "C"' module (which implicitly puts all
260  /// headers in it within an 'extern "C"' block, and allows the module to be
261  /// imported within such a block).
262  unsigned IsExternC : 1;
263 
264  /// Whether this is an inferred submodule (module * { ... }).
265  unsigned IsInferred : 1;
266 
267  /// Whether we should infer submodules for this module based on
268  /// the headers.
269  ///
270  /// Submodules can only be inferred for modules with an umbrella header.
271  unsigned InferSubmodules : 1;
272 
273  /// Whether, when inferring submodules, the inferred submodules
274  /// should be explicit.
276 
277  /// Whether, when inferring submodules, the inferr submodules should
278  /// export all modules they import (e.g., the equivalent of "export *").
279  unsigned InferExportWildcard : 1;
280 
281  /// Whether the set of configuration macros is exhaustive.
282  ///
283  /// When the set of configuration macros is exhaustive, meaning
284  /// that no identifier not in this list should affect how the module is
285  /// built.
287 
288  /// Whether files in this module can only include non-modular headers
289  /// and headers from used modules.
290  unsigned NoUndeclaredIncludes : 1;
291 
292  /// Whether this module came from a "private" module map, found next
293  /// to a regular (public) module map.
294  unsigned ModuleMapIsPrivate : 1;
295 
296  /// Whether Umbrella is a directory or header.
297  unsigned HasUmbrellaDir : 1;
298 
299  /// Describes the visibility of the various names within a
300  /// particular module.
302  /// All of the names in this module are hidden.
304  /// All of the names in this module are visible.
305  AllVisible
306  };
307 
308  /// The visibility of names within this particular module.
310 
311  /// The location of the inferred submodule.
313 
314  /// The set of modules imported by this module, and on which this
315  /// module depends.
317 
318  /// Describes an exported module.
319  ///
320  /// The pointer is the module being re-exported, while the bit will be true
321  /// to indicate that this is a wildcard export.
322  using ExportDecl = llvm::PointerIntPair<Module *, 1, bool>;
323 
324  /// The set of export declarations.
326 
327  /// Describes an exported module that has not yet been resolved
328  /// (perhaps because the module it refers to has not yet been loaded).
330  /// The location of the 'export' keyword in the module map file.
332 
333  /// The name of the module.
335 
336  /// Whether this export declaration ends in a wildcard, indicating
337  /// that all of its submodules should be exported (rather than the named
338  /// module itself).
339  bool Wildcard;
340  };
341 
342  /// The set of export declarations that have yet to be resolved.
344 
345  /// The directly used modules.
347 
348  /// The set of use declarations that have yet to be resolved.
350 
351  /// A library or framework to link against when an entity from this
352  /// module is used.
353  struct LinkLibrary {
354  LinkLibrary() = default;
355  LinkLibrary(const std::string &Library, bool IsFramework)
356  : Library(Library), IsFramework(IsFramework) {}
357 
358  /// The library to link against.
359  ///
360  /// This will typically be a library or framework name, but can also
361  /// be an absolute path to the library or framework.
362  std::string Library;
363 
364  /// Whether this is a framework rather than a library.
365  bool IsFramework = false;
366  };
367 
368  /// The set of libraries or frameworks to link against when
369  /// an entity from this module is used.
371 
372  /// Autolinking uses the framework name for linking purposes
373  /// when this is false and the export_as name otherwise.
374  bool UseExportAsModuleLinkName = false;
375 
376  /// The set of "configuration macros", which are macros that
377  /// (intentionally) change how this module is built.
378  std::vector<std::string> ConfigMacros;
379 
380  /// An unresolved conflict with another module.
382  /// The (unresolved) module id.
384 
385  /// The message provided to the user when there is a conflict.
386  std::string Message;
387  };
388 
389  /// The list of conflicts for which the module-id has not yet been
390  /// resolved.
391  std::vector<UnresolvedConflict> UnresolvedConflicts;
392 
393  /// A conflict between two modules.
394  struct Conflict {
395  /// The module that this module conflicts with.
397 
398  /// The message provided to the user when there is a conflict.
399  std::string Message;
400  };
401 
402  /// The list of conflicts.
403  std::vector<Conflict> Conflicts;
404 
405  /// Construct a new module or submodule.
406  Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent,
407  bool IsFramework, bool IsExplicit, unsigned VisibilityID);
408 
409  ~Module();
410 
411  /// Determine whether this module has been declared unimportable.
412  bool isUnimportable() const { return IsUnimportable; }
413 
414  /// Determine whether this module has been declared unimportable.
415  ///
416  /// \param LangOpts The language options used for the current
417  /// translation unit.
418  ///
419  /// \param Target The target options used for the current translation unit.
420  ///
421  /// \param Req If this module is unimportable because of a missing
422  /// requirement, this parameter will be set to one of the requirements that
423  /// is not met for use of this module.
424  ///
425  /// \param ShadowingModule If this module is unimportable because it is
426  /// shadowed, this parameter will be set to the shadowing module.
427  bool isUnimportable(const LangOptions &LangOpts, const TargetInfo &Target,
428  Requirement &Req, Module *&ShadowingModule) const;
429 
430  /// Determine whether this module is available for use within the
431  /// current translation unit.
432  bool isAvailable() const { return IsAvailable; }
433 
434  /// Determine whether this module is available for use within the
435  /// current translation unit.
436  ///
437  /// \param LangOpts The language options used for the current
438  /// translation unit.
439  ///
440  /// \param Target The target options used for the current translation unit.
441  ///
442  /// \param Req If this module is unavailable because of a missing requirement,
443  /// this parameter will be set to one of the requirements that is not met for
444  /// use of this module.
445  ///
446  /// \param MissingHeader If this module is unavailable because of a missing
447  /// header, this parameter will be set to one of the missing headers.
448  ///
449  /// \param ShadowingModule If this module is unavailable because it is
450  /// shadowed, this parameter will be set to the shadowing module.
451  bool isAvailable(const LangOptions &LangOpts,
452  const TargetInfo &Target,
453  Requirement &Req,
454  UnresolvedHeaderDirective &MissingHeader,
455  Module *&ShadowingModule) const;
456 
457  /// Determine whether this module is a submodule.
458  bool isSubModule() const { return Parent != nullptr; }
459 
460  /// Determine whether this module is a submodule of the given other
461  /// module.
462  bool isSubModuleOf(const Module *Other) const;
463 
464  /// Determine whether this module is a part of a framework,
465  /// either because it is a framework module or because it is a submodule
466  /// of a framework module.
467  bool isPartOfFramework() const {
468  for (const Module *Mod = this; Mod; Mod = Mod->Parent)
469  if (Mod->IsFramework)
470  return true;
471 
472  return false;
473  }
474 
475  /// Determine whether this module is a subframework of another
476  /// framework.
477  bool isSubFramework() const {
478  return IsFramework && Parent && Parent->isPartOfFramework();
479  }
480 
481  /// Set the parent of this module. This should only be used if the parent
482  /// could not be set during module creation.
483  void setParent(Module *M) {
484  assert(!Parent);
485  Parent = M;
486  Parent->SubModuleIndex[Name] = Parent->SubModules.size();
487  Parent->SubModules.push_back(this);
488  }
489 
490  /// Retrieve the full name of this module, including the path from
491  /// its top-level module.
492  /// \param AllowStringLiterals If \c true, components that might not be
493  /// lexically valid as identifiers will be emitted as string literals.
494  std::string getFullModuleName(bool AllowStringLiterals = false) const;
495 
496  /// Whether the full name of this module is equal to joining
497  /// \p nameParts with "."s.
498  ///
499  /// This is more efficient than getFullModuleName().
500  bool fullModuleNameIs(ArrayRef<StringRef> nameParts) const;
501 
502  /// Retrieve the top-level module for this (sub)module, which may
503  /// be this module.
505  return const_cast<Module *>(
506  const_cast<const Module *>(this)->getTopLevelModule());
507  }
508 
509  /// Retrieve the top-level module for this (sub)module, which may
510  /// be this module.
511  const Module *getTopLevelModule() const;
512 
513  /// Retrieve the name of the top-level module.
514  StringRef getTopLevelModuleName() const {
515  return getTopLevelModule()->Name;
516  }
517 
518  /// The serialized AST file for this module, if one was created.
519  const FileEntry *getASTFile() const {
520  return getTopLevelModule()->ASTFile;
521  }
522 
523  /// Set the serialized AST file for the top-level module of this module.
524  void setASTFile(const FileEntry *File) {
525  assert((File == nullptr || getASTFile() == nullptr ||
526  getASTFile() == File) && "file path changed");
527  getTopLevelModule()->ASTFile = File;
528  }
529 
530  /// Retrieve the directory for which this module serves as the
531  /// umbrella.
532  DirectoryName getUmbrellaDir() const;
533 
534  /// Retrieve the header that serves as the umbrella header for this
535  /// module.
537  if (!HasUmbrellaDir)
538  return Header{UmbrellaAsWritten,
539  static_cast<const FileEntry *>(Umbrella)};
540  return Header{};
541  }
542 
543  /// Determine whether this module has an umbrella directory that is
544  /// not based on an umbrella header.
545  bool hasUmbrellaDir() const { return Umbrella && HasUmbrellaDir; }
546 
547  /// Add a top-level header associated with this module.
548  void addTopHeader(const FileEntry *File);
549 
550  /// Add a top-level header filename associated with this module.
551  void addTopHeaderFilename(StringRef Filename) {
552  TopHeaderNames.push_back(std::string(Filename));
553  }
554 
555  /// The top-level headers associated with this module.
556  ArrayRef<const FileEntry *> getTopHeaders(FileManager &FileMgr);
557 
558  /// Determine whether this module has declared its intention to
559  /// directly use another module.
560  bool directlyUses(const Module *Requested) const;
561 
562  /// Add the given feature requirement to the list of features
563  /// required by this module.
564  ///
565  /// \param Feature The feature that is required by this module (and
566  /// its submodules).
567  ///
568  /// \param RequiredState The required state of this feature: \c true
569  /// if it must be present, \c false if it must be absent.
570  ///
571  /// \param LangOpts The set of language options that will be used to
572  /// evaluate the availability of this feature.
573  ///
574  /// \param Target The target options that will be used to evaluate the
575  /// availability of this feature.
576  void addRequirement(StringRef Feature, bool RequiredState,
577  const LangOptions &LangOpts,
578  const TargetInfo &Target);
579 
580  /// Mark this module and all of its submodules as unavailable.
581  void markUnavailable(bool Unimportable);
582 
583  /// Find the submodule with the given name.
584  ///
585  /// \returns The submodule if found, or NULL otherwise.
586  Module *findSubmodule(StringRef Name) const;
587  Module *findOrInferSubmodule(StringRef Name);
588 
589  /// Determine whether the specified module would be visible to
590  /// a lookup at the end of this module.
591  ///
592  /// FIXME: This may return incorrect results for (submodules of) the
593  /// module currently being built, if it's queried before we see all
594  /// of its imports.
595  bool isModuleVisible(const Module *M) const {
596  if (VisibleModulesCache.empty())
597  buildVisibleModulesCache();
598  return VisibleModulesCache.count(M);
599  }
600 
601  unsigned getVisibilityID() const { return VisibilityID; }
602 
603  using submodule_iterator = std::vector<Module *>::iterator;
604  using submodule_const_iterator = std::vector<Module *>::const_iterator;
605 
606  submodule_iterator submodule_begin() { return SubModules.begin(); }
607  submodule_const_iterator submodule_begin() const {return SubModules.begin();}
608  submodule_iterator submodule_end() { return SubModules.end(); }
609  submodule_const_iterator submodule_end() const { return SubModules.end(); }
610 
611  llvm::iterator_range<submodule_iterator> submodules() {
612  return llvm::make_range(submodule_begin(), submodule_end());
613  }
614  llvm::iterator_range<submodule_const_iterator> submodules() const {
615  return llvm::make_range(submodule_begin(), submodule_end());
616  }
617 
618  /// Appends this module's list of exported modules to \p Exported.
619  ///
620  /// This provides a subset of immediately imported modules (the ones that are
621  /// directly exported), not the complete set of exported modules.
622  void getExportedModules(SmallVectorImpl<Module *> &Exported) const;
623 
624  static StringRef getModuleInputBufferName() {
625  return "<module-includes>";
626  }
627 
628  /// Print the module map for this module to the given stream.
629  void print(raw_ostream &OS, unsigned Indent = 0) const;
630 
631  /// Dump the contents of this module to the given output stream.
632  void dump() const;
633 
634 private:
635  void buildVisibleModulesCache() const;
636 };
637 
638 /// A set of visible modules.
640 public:
641  VisibleModuleSet() = default;
643  : ImportLocs(std::move(O.ImportLocs)), Generation(O.Generation ? 1 : 0) {
644  O.ImportLocs.clear();
645  ++O.Generation;
646  }
647 
648  /// Move from another visible modules set. Guaranteed to leave the source
649  /// empty and bump the generation on both.
651  ImportLocs = std::move(O.ImportLocs);
652  O.ImportLocs.clear();
653  ++O.Generation;
654  ++Generation;
655  return *this;
656  }
657 
658  /// Get the current visibility generation. Incremented each time the
659  /// set of visible modules changes in any way.
660  unsigned getGeneration() const { return Generation; }
661 
662  /// Determine whether a module is visible.
663  bool isVisible(const Module *M) const {
664  return getImportLoc(M).isValid();
665  }
666 
667  /// Get the location at which the import of a module was triggered.
669  return M->getVisibilityID() < ImportLocs.size()
670  ? ImportLocs[M->getVisibilityID()]
671  : SourceLocation();
672  }
673 
674  /// A callback to call when a module is made visible (directly or
675  /// indirectly) by a call to \ref setVisible.
676  using VisibleCallback = llvm::function_ref<void(Module *M)>;
677 
678  /// A callback to call when a module conflict is found. \p Path
679  /// consists of a sequence of modules from the conflicting module to the one
680  /// made visible, where each was exported by the next.
681  using ConflictCallback =
682  llvm::function_ref<void(ArrayRef<Module *> Path, Module *Conflict,
683  StringRef Message)>;
684 
685  /// Make a specific module visible.
686  void setVisible(Module *M, SourceLocation Loc,
687  VisibleCallback Vis = [](Module *) {},
689  StringRef) {});
690 
691 private:
692  /// Import locations for each visible module. Indexed by the module's
693  /// VisibilityID.
694  std::vector<SourceLocation> ImportLocs;
695 
696  /// Visibility generation, bumped every time the visibility state changes.
697  unsigned Generation = 0;
698 };
699 
700 /// Abstracts clang modules and precompiled header files and holds
701 /// everything needed to generate debug info for an imported module
702 /// or PCH.
704  StringRef PCHModuleName;
705  StringRef Path;
706  StringRef ASTFile;
707  ASTFileSignature Signature;
708  Module *ClangModule = nullptr;
709 
710 public:
711  ASTSourceDescriptor() = default;
712  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
713  ASTFileSignature Signature)
714  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
715  ASTFile(std::move(ASTFile)), Signature(Signature) {}
717 
718  std::string getModuleName() const;
719  StringRef getPath() const { return Path; }
720  StringRef getASTFile() const { return ASTFile; }
721  ASTFileSignature getSignature() const { return Signature; }
722  Module *getModuleOrNull() const { return ClangModule; }
723 };
724 
725 
726 } // namespace clang
727 
728 #endif // LLVM_CLANG_BASIC_MODULE_H
SourceLocation ExportLoc
The location of the &#39;export&#39; keyword in the module map file.
Definition: Module.h:331
unsigned IsAvailable
Whether this module is available in the current translation unit.
Definition: Module.h:244
SmallVector< UnresolvedExportDecl, 2 > UnresolvedExports
The set of export declarations that have yet to be resolved.
Definition: Module.h:343
ASTFileSignature Signature
The module signature.
Definition: Module.h:130
std::string Name
The name of this module.
Definition: Module.h:90
A set of visible modules.
Definition: Module.h:639
ASTFileSignature getSignature() const
Definition: Module.h:721
StringRef getASTFile() const
Definition: Module.h:720
SmallVector< UnresolvedHeaderDirective, 1 > MissingHeaders
Headers that are mentioned in the module map file but could not be found on the file system...
Definition: Module.h:217
std::string Message
The message provided to the user when there is a conflict.
Definition: Module.h:386
bool isSubFramework() const
Determine whether this module is a subframework of another framework.
Definition: Module.h:477
std::vector< Module * >::iterator submodule_iterator
Definition: Module.h:603
Implements support for file system lookup, file system caching, and directory search management...
Definition: FileManager.h:172
An unresolved conflict with another module.
Definition: Module.h:381
unsigned getVisibilityID() const
Definition: Module.h:601
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
Definition: Dominators.h:30
submodule_iterator submodule_begin()
Definition: Module.h:606
unsigned IsExternC
Whether this is an &#39;extern "C"&#39; module (which implicitly puts all headers in it within an &#39;extern "C"...
Definition: Module.h:262
void addTopHeaderFilename(StringRef Filename)
Add a top-level header filename associated with this module.
Definition: Module.h:551
Module * getTopLevelModule()
Retrieve the top-level module for this (sub)module, which may be this module.
Definition: Module.h:504
std::vector< UnresolvedConflict > UnresolvedConflicts
The list of conflicts for which the module-id has not yet been resolved.
Definition: Module.h:391
ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile, ASTFileSignature Signature)
Definition: Module.h:712
unsigned IsFramework
Whether this is a framework module.
Definition: Module.h:250
SourceLocation getImportLoc(const Module *M) const
Get the location at which the import of a module was triggered.
Definition: Module.h:668
const FileEntry * getASTFile() const
The serialized AST file for this module, if one was created.
Definition: Module.h:519
bool hasUmbrellaDir() const
Determine whether this module has an umbrella directory that is not based on an umbrella header...
Definition: Module.h:545
This is a module that was defined by a module map and built out of header files.
Definition: Module.h:98
float __ovld __cnfn distance(float p0, float p1)
Returns the distance between p0 and p1.
Abstracts clang modules and precompiled header files and holds everything needed to generate debug in...
Definition: Module.h:703
void print(llvm::raw_ostream &OS, const Pointer &P, ASTContext &Ctx, QualType Ty)
Definition: InterpFrame.cpp:62
std::string PresumedModuleMapFile
The presumed file name for the module map defining this module.
Definition: Module.h:124
bool isPartOfFramework() const
Determine whether this module is a part of a framework, either because it is a framework module or be...
Definition: Module.h:467
This is the private module fragment within some C++ module.
Definition: Module.h:107
ASTFileSignature(BaseT S={{0}})
Definition: Module.h:61
A library or framework to link against when an entity from this module is used.
Definition: Module.h:353
static StringRef getModuleInputBufferName()
Definition: Module.h:624
SmallVector< Requirement, 2 > Requirements
The set of language features required to use this module.
Definition: Module.h:227
Module * getModuleOrNull() const
Definition: Module.h:722
Definition: Format.h:2679
Header getUmbrellaHeader() const
Retrieve the header that serves as the umbrella header for this module.
Definition: Module.h:536
bool isVisible(const Module *M) const
Determine whether a module is visible.
Definition: Module.h:663
The signature of a module, which is a hash of the AST content.
Definition: Module.h:56
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:54
Describes a module or submodule.
Definition: Module.h:87
StringRef getTopLevelModuleName() const
Retrieve the name of the top-level module.
Definition: Module.h:514
unsigned InferExportWildcard
Whether, when inferring submodules, the inferr submodules should export all modules they import (e...
Definition: Module.h:279
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
std::string Message
The message provided to the user when there is a conflict.
Definition: Module.h:399
ModuleId Id
The (unresolved) module id.
Definition: Module.h:383
Module * Parent
The parent of this module.
Definition: Module.h:115
unsigned IsInferred
Whether this is an inferred submodule (module * { ... }).
Definition: Module.h:265
unsigned IsFromModuleFile
Whether this module was loaded from a module file.
Definition: Module.h:247
submodule_iterator submodule_end()
Definition: Module.h:608
LinkLibrary(const std::string &Library, bool IsFramework)
Definition: Module.h:355
VisibleModuleSet(VisibleModuleSet &&O)
Definition: Module.h:642
unsigned NoUndeclaredIncludes
Whether files in this module can only include non-modular headers and headers from used modules...
Definition: Module.h:290
unsigned IsSystem
Whether this is a "system" module (which assumes that all headers in it are system headers)...
Definition: Module.h:257
void setParent(Module *M)
Set the parent of this module.
Definition: Module.h:483
llvm::SmallSetVector< Module *, 2 > Imports
The set of modules imported by this module, and on which this module depends.
Definition: Module.h:316
StringRef Filename
Definition: Format.cpp:2018
std::string Library
The library to link against.
Definition: Module.h:362
const DirectoryEntry * Entry
Definition: Module.h:191
Exposes information about the current target.
Definition: TargetInfo.h:179
SmallVector< ModuleId, 2 > UnresolvedDirectUses
The set of use declarations that have yet to be resolved.
Definition: Module.h:349
ModuleId Id
The name of the module.
Definition: Module.h:334
VisibleModuleSet & operator=(VisibleModuleSet &&O)
Move from another visible modules set.
Definition: Module.h:650
unsigned ConfigMacrosExhaustive
Whether the set of configuration macros is exhaustive.
Definition: Module.h:286
#define bool
Definition: stdbool.h:15
static ASTFileSignature create(InputIt First, InputIt Last)
Definition: Module.h:76
llvm::SmallVector< LinkLibrary, 2 > LinkLibraries
The set of libraries or frameworks to link against when an entity from this module is used...
Definition: Module.h:370
StringRef getPath() const
Definition: Module.h:719
std::string NameAsWritten
Definition: Module.h:181
bool isAvailable() const
Determine whether this module is available for use within the current translation unit...
Definition: Module.h:432
Information about a header directive as found in the module map file.
Definition: Module.h:180
SmallVector< ExportDecl, 2 > Exports
The set of export declarations.
Definition: Module.h:325
llvm::function_ref< void(ArrayRef< Module * > Path, Module *Conflict, StringRef Message)> ConflictCallback
A callback to call when a module conflict is found.
Definition: Module.h:683
Kind
void setASTFile(const FileEntry *File)
Set the serialized AST file for the top-level module of this module.
Definition: Module.h:524
bool isUnimportable() const
Determine whether this module has been declared unimportable.
Definition: Module.h:412
Encodes a location in the source.
std::string ExportAsModule
The module through which entities defined in this module will eventually be exposed, for use in "private" modules.
Definition: Module.h:137
NameVisibilityKind NameVisibility
The visibility of names within this particular module.
Definition: Module.h:309
All of the names in this module are hidden.
Definition: Module.h:303
Information about a directory name as found in the module map file.
Definition: Module.h:189
Cached information about one file (either on disk or in the virtual file system). ...
Definition: FileManager.h:79
unsigned IsUnimportable
Whether this module has declared itself unimportable, either because it&#39;s missing a requirement from ...
Definition: Module.h:235
const FileEntry * Entry
Definition: Module.h:182
bool isModuleVisible(const Module *M) const
Determine whether the specified module would be visible to a lookup at the end of this module...
Definition: Module.h:595
This is a fragment of the global module within some C++ module.
Definition: Module.h:104
bool Wildcard
Whether this export declaration ends in a wildcard, indicating that all of its submodules should be e...
Definition: Module.h:339
std::pair< std::string, bool > Requirement
An individual requirement: a feature name and a flag indicating the required state of that feature...
Definition: Module.h:221
llvm::iterator_range< submodule_const_iterator > submodules() const
Definition: Module.h:614
unsigned HasUmbrellaDir
Whether Umbrella is a directory or header.
Definition: Module.h:297
bool isSubModule() const
Determine whether this module is a submodule.
Definition: Module.h:458
A conflict between two modules.
Definition: Module.h:394
SmallVector< UnresolvedHeaderDirective, 1 > UnresolvedHeaders
Headers that are mentioned in the module map file but that we have not yet attempted to resolve to a ...
Definition: Module.h:213
Dataflow Directional Tag Classes.
Stored information about a header directive that was found in the module map file but has not been re...
Definition: Module.h:201
SourceLocation InferredSubmoduleLoc
The location of the inferred submodule.
Definition: Module.h:312
llvm::iterator_range< submodule_iterator > submodules()
Definition: Module.h:611
std::unique_ptr< DiagnosticConsumer > create(StringRef OutputFile, DiagnosticOptions *Diags, bool MergeChildRecords=false)
Returns a DiagnosticConsumer that serializes diagnostics to a bitcode file.
llvm::PointerIntPair< Module *, 1, bool > ExportDecl
Describes an exported module.
Definition: Module.h:322
static ASTFileSignature createDISentinel()
Definition: Module.h:69
unsigned ModuleMapIsPrivate
Whether this module came from a "private" module map, found next to a regular (public) module map...
Definition: Module.h:294
SourceLocation DefinitionLoc
The location of the module definition.
Definition: Module.h:93
bool isModulePurview() const
Does this Module scope describe part of the purview of a named C++ module?
Definition: Module.h:140
std::vector< Conflict > Conflicts
The list of conflicts.
Definition: Module.h:403
SmallVector< Module *, 2 > DirectUses
The directly used modules.
Definition: Module.h:346
Describes an exported module that has not yet been resolved (perhaps because the module it refers to ...
Definition: Module.h:329
unsigned getGeneration() const
Get the current visibility generation.
Definition: Module.h:660
std::string NameAsWritten
Definition: Module.h:190
Cached information about one directory (either on disk or in the virtual file system).
Definition: FileManager.h:46
submodule_const_iterator submodule_begin() const
Definition: Module.h:607
llvm::function_ref< void(Module *M)> VisibleCallback
A callback to call when a module is made visible (directly or indirectly) by a call to setVisible...
Definition: Module.h:676
Defines the clang::SourceLocation class and associated facilities.
unsigned InferSubmodules
Whether we should infer submodules for this module based on the headers.
Definition: Module.h:271
unsigned HasIncompatibleModuleFile
Whether we tried and failed to load a module file for this module.
Definition: Module.h:238
NameVisibilityKind
Describes the visibility of the various names within a particular module.
Definition: Module.h:301
std::vector< std::string > ConfigMacros
The set of "configuration macros", which are macros that (intentionally) change how this module is bu...
Definition: Module.h:378
submodule_const_iterator submodule_end() const
Definition: Module.h:609
std::array< uint8_t, 20 > BaseT
Definition: Module.h:57
std::string UmbrellaAsWritten
The name of the umbrella entry, as written in the module map.
Definition: Module.h:133
Module * Other
The module that this module conflicts with.
Definition: Module.h:396
unsigned IsExplicit
Whether this is an explicit submodule.
Definition: Module.h:253
static ASTFileSignature create(StringRef Bytes)
Definition: Module.h:65
std::vector< Module * >::const_iterator submodule_const_iterator
Definition: Module.h:604
unsigned InferExplicitSubmodules
Whether, when inferring submodules, the inferred submodules should be explicit.
Definition: Module.h:275
This is a C++ Modules TS module interface unit.
Definition: Module.h:101