]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/clang/include/clang/Basic/Module.h
Merge ^/head r363989 through r364034.
[FreeBSD/FreeBSD.git] / contrib / llvm-project / clang / include / clang / Basic / Module.h
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
18 #include "clang/Basic/SourceLocation.h"
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.
53 using ModuleId = SmallVector<std::pair<std::string, SourceLocation>, 2>;
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
69   static ASTFileSignature createDISentinel() {
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.
93   SourceLocation DefinitionLoc;
94
95   enum ModuleKind {
96     /// This is a module that was defined by a module map and built out
97     /// of header files.
98     ModuleMapModule,
99
100     /// This is a C++ Modules TS module interface unit.
101     ModuleInterfaceUnit,
102
103     /// This is a fragment of the global module within some C++ module.
104     GlobalModuleFragment,
105
106     /// This is the private module fragment within some C++ module.
107     PrivateModuleFragment,
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.
115   Module *Parent;
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.
124   std::string PresumedModuleMapFile;
125
126   /// The umbrella header or directory.
127   const void *Umbrella = nullptr;
128
129   /// The module signature.
130   ASTFileSignature 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.
157   llvm::SmallSetVector<const FileEntry *, 2> TopHeaders;
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 {
170     HK_Normal,
171     HK_Textual,
172     HK_Private,
173     HK_PrivateTextual,
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;
191     const DirectoryEntry *Entry;
192
193     explicit operator bool() { return Entry; }
194   };
195
196   /// The headers that are part of this module.
197   SmallVector<Header, 2> Headers[5];
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.
201   struct UnresolvedHeaderDirective {
202     HeaderKind Kind = HK_Normal;
203     SourceLocation FileNameLoc;
204     std::string FileName;
205     bool IsUmbrella = false;
206     bool HasBuiltinHeader = false;
207     Optional<off_t> Size;
208     Optional<time_t> ModTime;
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.
213   SmallVector<UnresolvedHeaderDirective, 1> UnresolvedHeaders;
214
215   /// Headers that are mentioned in the module map file but could not be
216   /// found on the file system.
217   SmallVector<UnresolvedHeaderDirective, 1> MissingHeaders;
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.
227   SmallVector<Requirement, 2> Requirements;
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.
238   unsigned HasIncompatibleModuleFile : 1;
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.
275   unsigned InferExplicitSubmodules : 1;
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.
286   unsigned ConfigMacrosExhaustive : 1;
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.
301   enum NameVisibilityKind {
302     /// All of the names in this module are hidden.
303     Hidden,
304     /// All of the names in this module are visible.
305     AllVisible
306   };
307
308   /// The visibility of names within this particular module.
309   NameVisibilityKind NameVisibility;
310
311   /// The location of the inferred submodule.
312   SourceLocation InferredSubmoduleLoc;
313
314   /// The set of modules imported by this module, and on which this
315   /// module depends.
316   llvm::SmallSetVector<Module *, 2> Imports;
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.
325   SmallVector<ExportDecl, 2> Exports;
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).
329   struct UnresolvedExportDecl {
330     /// The location of the 'export' keyword in the module map file.
331     SourceLocation ExportLoc;
332
333     /// The name of the module.
334     ModuleId Id;
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.
343   SmallVector<UnresolvedExportDecl, 2> UnresolvedExports;
344
345   /// The directly used modules.
346   SmallVector<Module *, 2> DirectUses;
347
348   /// The set of use declarations that have yet to be resolved.
349   SmallVector<ModuleId, 2> UnresolvedDirectUses;
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.
370   llvm::SmallVector<LinkLibrary, 2> LinkLibraries;
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.
381   struct UnresolvedConflict {
382     /// The (unresolved) module id.
383     ModuleId 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.
396     Module *Other;
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.
504   Module *getTopLevelModule() {
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.
536   Header getUmbrellaHeader() const {
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.
639 class VisibleModuleSet {
640 public:
641   VisibleModuleSet() = default;
642   VisibleModuleSet(VisibleModuleSet &&O)
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.
650   VisibleModuleSet &operator=(VisibleModuleSet &&O) {
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.
668   SourceLocation getImportLoc(const Module *M) const {
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 *) {},
688                   ConflictCallback Cb = [](ArrayRef<Module *>, 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.
703 class ASTSourceDescriptor {
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) {}
716   ASTSourceDescriptor(Module &M);
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