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