1 //===-- CompilerInstance.h - Clang Compiler Instance ------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_CLANG_FRONTEND_COMPILERINSTANCE_H_
11 #define LLVM_CLANG_FRONTEND_COMPILERINSTANCE_H_
13 #include "clang/AST/ASTConsumer.h"
14 #include "clang/Basic/Diagnostic.h"
15 #include "clang/Basic/SourceManager.h"
16 #include "clang/Frontend/CompilerInvocation.h"
17 #include "clang/Frontend/PCHContainerOperations.h"
18 #include "clang/Frontend/Utils.h"
19 #include "clang/Lex/HeaderSearchOptions.h"
20 #include "clang/Lex/ModuleLoader.h"
21 #include "llvm/ADT/ArrayRef.h"
22 #include "llvm/ADT/DenseMap.h"
23 #include "llvm/ADT/IntrusiveRefCntPtr.h"
24 #include "llvm/ADT/StringRef.h"
40 class CodeCompleteConsumer;
41 class DiagnosticsEngine;
42 class DiagnosticConsumer;
43 class ExternalASTSource;
47 class MemoryBufferCache;
54 /// CompilerInstance - Helper class for managing a single instance of the Clang
57 /// The CompilerInstance serves two purposes:
58 /// (1) It manages the various objects which are necessary to run the compiler,
59 /// for example the preprocessor, the target information, and the AST
61 /// (2) It provides utility routines for constructing and manipulating the
62 /// common Clang objects.
64 /// The compiler instance generally owns the instance of all the objects that it
65 /// manages. However, clients can still share objects by manually setting the
66 /// object and retaking ownership prior to destroying the CompilerInstance.
68 /// The compiler instance is intended to simplify clients, but not to lock them
69 /// in to the compiler instance for everything. When possible, utility functions
70 /// come in two forms; a short form that reuses the CompilerInstance objects,
71 /// and a long form that takes explicit instances of any required objects.
72 class CompilerInstance : public ModuleLoader {
73 /// The options used in this compiler instance.
74 std::shared_ptr<CompilerInvocation> Invocation;
76 /// The diagnostics engine instance.
77 IntrusiveRefCntPtr<DiagnosticsEngine> Diagnostics;
79 /// The target being compiled for.
80 IntrusiveRefCntPtr<TargetInfo> Target;
82 /// Auxiliary Target info.
83 IntrusiveRefCntPtr<TargetInfo> AuxTarget;
85 /// The virtual file system.
86 IntrusiveRefCntPtr<vfs::FileSystem> VirtualFileSystem;
89 IntrusiveRefCntPtr<FileManager> FileMgr;
91 /// The source manager.
92 IntrusiveRefCntPtr<SourceManager> SourceMgr;
94 /// The cache of PCM files.
95 IntrusiveRefCntPtr<MemoryBufferCache> PCMCache;
98 std::shared_ptr<Preprocessor> PP;
101 IntrusiveRefCntPtr<ASTContext> Context;
103 /// An optional sema source that will be attached to sema.
104 IntrusiveRefCntPtr<ExternalSemaSource> ExternalSemaSrc;
106 /// The AST consumer.
107 std::unique_ptr<ASTConsumer> Consumer;
109 /// The code completion consumer.
110 std::unique_ptr<CodeCompleteConsumer> CompletionConsumer;
112 /// \brief The semantic analysis object.
113 std::unique_ptr<Sema> TheSema;
115 /// \brief The frontend timer group.
116 std::unique_ptr<llvm::TimerGroup> FrontendTimerGroup;
118 /// \brief The frontend timer.
119 std::unique_ptr<llvm::Timer> FrontendTimer;
121 /// \brief The ASTReader, if one exists.
122 IntrusiveRefCntPtr<ASTReader> ModuleManager;
124 /// \brief The module dependency collector for crashdumps
125 std::shared_ptr<ModuleDependencyCollector> ModuleDepCollector;
127 /// \brief The module provider.
128 std::shared_ptr<PCHContainerOperations> ThePCHContainerOperations;
130 /// \brief The dependency file generator.
131 std::unique_ptr<DependencyFileGenerator> TheDependencyFileGenerator;
133 std::vector<std::shared_ptr<DependencyCollector>> DependencyCollectors;
135 /// \brief The set of top-level modules that has already been loaded,
136 /// along with the module map
137 llvm::DenseMap<const IdentifierInfo *, Module *> KnownModules;
139 /// \brief The set of top-level modules that has already been built on the
140 /// fly as part of this overall compilation action.
141 std::map<std::string, std::string> BuiltModules;
143 /// Should we delete the BuiltModules when we're done?
144 bool DeleteBuiltModules = true;
146 /// \brief The location of the module-import keyword for the last module
148 SourceLocation LastModuleImportLoc;
150 /// \brief The result of the last module import.
152 ModuleLoadResult LastModuleImportResult;
154 /// \brief Whether we should (re)build the global module index once we
155 /// have finished with this translation unit.
156 bool BuildGlobalModuleIndex = false;
158 /// \brief We have a full global module index, with all modules.
159 bool HaveFullGlobalModuleIndex = false;
161 /// \brief One or more modules failed to build.
162 bool ModuleBuildFailed = false;
164 /// \brief Holds information about the output file.
166 /// If TempFilename is not empty we must rename it to Filename at the end.
167 /// TempFilename may be empty and Filename non-empty if creating the temporary
170 std::string Filename;
171 std::string TempFilename;
173 OutputFile(std::string filename, std::string tempFilename)
174 : Filename(std::move(filename)), TempFilename(std::move(tempFilename)) {
178 /// If the output doesn't support seeking (terminal, pipe). we switch
179 /// the stream to a buffer_ostream. These are the buffer and the original
181 std::unique_ptr<llvm::raw_fd_ostream> NonSeekStream;
183 /// The list of active output files.
184 std::list<OutputFile> OutputFiles;
186 CompilerInstance(const CompilerInstance &) = delete;
187 void operator=(const CompilerInstance &) = delete;
189 explicit CompilerInstance(
190 std::shared_ptr<PCHContainerOperations> PCHContainerOps =
191 std::make_shared<PCHContainerOperations>(),
192 MemoryBufferCache *SharedPCMCache = nullptr);
193 ~CompilerInstance() override;
195 /// @name High-Level Operations
198 /// ExecuteAction - Execute the provided action against the compiler's
199 /// CompilerInvocation object.
201 /// This function makes the following assumptions:
203 /// - The invocation options should be initialized. This function does not
204 /// handle the '-help' or '-version' options, clients should handle those
207 /// - The diagnostics engine should have already been created by the client.
209 /// - No other CompilerInstance state should have been initialized (this is
210 /// an unchecked error).
212 /// - Clients should have initialized any LLVM target features that may be
215 /// - Clients should eventually call llvm_shutdown() upon the completion of
216 /// this routine to ensure that any managed objects are properly destroyed.
218 /// Note that this routine may write output to 'stderr'.
220 /// \param Act - The action to execute.
221 /// \return - True on success.
223 // FIXME: This function should take the stream to write any debugging /
224 // verbose output to as an argument.
226 // FIXME: Eliminate the llvm_shutdown requirement, that should either be part
227 // of the context or else not CompilerInstance specific.
228 bool ExecuteAction(FrontendAction &Act);
231 /// @name Compiler Invocation and Options
234 bool hasInvocation() const { return Invocation != nullptr; }
236 CompilerInvocation &getInvocation() {
237 assert(Invocation && "Compiler instance has no invocation!");
241 /// setInvocation - Replace the current invocation.
242 void setInvocation(std::shared_ptr<CompilerInvocation> Value);
244 /// \brief Indicates whether we should (re)build the global module index.
245 bool shouldBuildGlobalModuleIndex() const;
247 /// \brief Set the flag indicating whether we should (re)build the global
249 void setBuildGlobalModuleIndex(bool Build) {
250 BuildGlobalModuleIndex = Build;
254 /// @name Forwarding Methods
257 AnalyzerOptionsRef getAnalyzerOpts() {
258 return Invocation->getAnalyzerOpts();
261 CodeGenOptions &getCodeGenOpts() {
262 return Invocation->getCodeGenOpts();
264 const CodeGenOptions &getCodeGenOpts() const {
265 return Invocation->getCodeGenOpts();
268 DependencyOutputOptions &getDependencyOutputOpts() {
269 return Invocation->getDependencyOutputOpts();
271 const DependencyOutputOptions &getDependencyOutputOpts() const {
272 return Invocation->getDependencyOutputOpts();
275 DiagnosticOptions &getDiagnosticOpts() {
276 return Invocation->getDiagnosticOpts();
278 const DiagnosticOptions &getDiagnosticOpts() const {
279 return Invocation->getDiagnosticOpts();
282 FileSystemOptions &getFileSystemOpts() {
283 return Invocation->getFileSystemOpts();
285 const FileSystemOptions &getFileSystemOpts() const {
286 return Invocation->getFileSystemOpts();
289 FrontendOptions &getFrontendOpts() {
290 return Invocation->getFrontendOpts();
292 const FrontendOptions &getFrontendOpts() const {
293 return Invocation->getFrontendOpts();
296 HeaderSearchOptions &getHeaderSearchOpts() {
297 return Invocation->getHeaderSearchOpts();
299 const HeaderSearchOptions &getHeaderSearchOpts() const {
300 return Invocation->getHeaderSearchOpts();
302 std::shared_ptr<HeaderSearchOptions> getHeaderSearchOptsPtr() const {
303 return Invocation->getHeaderSearchOptsPtr();
306 LangOptions &getLangOpts() {
307 return *Invocation->getLangOpts();
309 const LangOptions &getLangOpts() const {
310 return *Invocation->getLangOpts();
313 PreprocessorOptions &getPreprocessorOpts() {
314 return Invocation->getPreprocessorOpts();
316 const PreprocessorOptions &getPreprocessorOpts() const {
317 return Invocation->getPreprocessorOpts();
320 PreprocessorOutputOptions &getPreprocessorOutputOpts() {
321 return Invocation->getPreprocessorOutputOpts();
323 const PreprocessorOutputOptions &getPreprocessorOutputOpts() const {
324 return Invocation->getPreprocessorOutputOpts();
327 TargetOptions &getTargetOpts() {
328 return Invocation->getTargetOpts();
330 const TargetOptions &getTargetOpts() const {
331 return Invocation->getTargetOpts();
335 /// @name Diagnostics Engine
338 bool hasDiagnostics() const { return Diagnostics != nullptr; }
340 /// Get the current diagnostics engine.
341 DiagnosticsEngine &getDiagnostics() const {
342 assert(Diagnostics && "Compiler instance has no diagnostics!");
346 /// setDiagnostics - Replace the current diagnostics engine.
347 void setDiagnostics(DiagnosticsEngine *Value);
349 DiagnosticConsumer &getDiagnosticClient() const {
350 assert(Diagnostics && Diagnostics->getClient() &&
351 "Compiler instance has no diagnostic client!");
352 return *Diagnostics->getClient();
356 /// @name Target Info
359 bool hasTarget() const { return Target != nullptr; }
361 TargetInfo &getTarget() const {
362 assert(Target && "Compiler instance has no target!");
366 /// Replace the current Target.
367 void setTarget(TargetInfo *Value);
370 /// @name AuxTarget Info
373 TargetInfo *getAuxTarget() const { return AuxTarget.get(); }
375 /// Replace the current AuxTarget.
376 void setAuxTarget(TargetInfo *Value);
379 /// @name Virtual File System
382 bool hasVirtualFileSystem() const { return VirtualFileSystem != nullptr; }
384 vfs::FileSystem &getVirtualFileSystem() const {
385 assert(hasVirtualFileSystem() &&
386 "Compiler instance has no virtual file system");
387 return *VirtualFileSystem;
390 /// \brief Replace the current virtual file system.
392 /// \note Most clients should use setFileManager, which will implicitly reset
393 /// the virtual file system to the one contained in the file manager.
394 void setVirtualFileSystem(IntrusiveRefCntPtr<vfs::FileSystem> FS) {
395 VirtualFileSystem = std::move(FS);
399 /// @name File Manager
402 bool hasFileManager() const { return FileMgr != nullptr; }
404 /// Return the current file manager to the caller.
405 FileManager &getFileManager() const {
406 assert(FileMgr && "Compiler instance has no file manager!");
410 void resetAndLeakFileManager() {
411 BuryPointer(FileMgr.get());
412 FileMgr.resetWithoutRelease();
415 /// \brief Replace the current file manager and virtual file system.
416 void setFileManager(FileManager *Value);
419 /// @name Source Manager
422 bool hasSourceManager() const { return SourceMgr != nullptr; }
424 /// Return the current source manager.
425 SourceManager &getSourceManager() const {
426 assert(SourceMgr && "Compiler instance has no source manager!");
430 void resetAndLeakSourceManager() {
431 BuryPointer(SourceMgr.get());
432 SourceMgr.resetWithoutRelease();
435 /// setSourceManager - Replace the current source manager.
436 void setSourceManager(SourceManager *Value);
439 /// @name Preprocessor
442 bool hasPreprocessor() const { return PP != nullptr; }
444 /// Return the current preprocessor.
445 Preprocessor &getPreprocessor() const {
446 assert(PP && "Compiler instance has no preprocessor!");
450 std::shared_ptr<Preprocessor> getPreprocessorPtr() { return PP; }
452 void resetAndLeakPreprocessor() {
453 BuryPointer(new std::shared_ptr<Preprocessor>(PP));
456 /// Replace the current preprocessor.
457 void setPreprocessor(std::shared_ptr<Preprocessor> Value);
463 bool hasASTContext() const { return Context != nullptr; }
465 ASTContext &getASTContext() const {
466 assert(Context && "Compiler instance has no AST context!");
470 void resetAndLeakASTContext() {
471 BuryPointer(Context.get());
472 Context.resetWithoutRelease();
475 /// setASTContext - Replace the current AST context.
476 void setASTContext(ASTContext *Value);
478 /// \brief Replace the current Sema; the compiler instance takes ownership
480 void setSema(Sema *S);
483 /// @name ASTConsumer
486 bool hasASTConsumer() const { return (bool)Consumer; }
488 ASTConsumer &getASTConsumer() const {
489 assert(Consumer && "Compiler instance has no AST consumer!");
493 /// takeASTConsumer - Remove the current AST consumer and give ownership to
495 std::unique_ptr<ASTConsumer> takeASTConsumer() { return std::move(Consumer); }
497 /// setASTConsumer - Replace the current AST consumer; the compiler instance
498 /// takes ownership of \p Value.
499 void setASTConsumer(std::unique_ptr<ASTConsumer> Value);
502 /// @name Semantic analysis
504 bool hasSema() const { return (bool)TheSema; }
506 Sema &getSema() const {
507 assert(TheSema && "Compiler instance has no Sema object!");
511 std::unique_ptr<Sema> takeSema();
512 void resetAndLeakSema();
515 /// @name Module Management
518 IntrusiveRefCntPtr<ASTReader> getModuleManager() const;
519 void setModuleManager(IntrusiveRefCntPtr<ASTReader> Reader);
521 std::shared_ptr<ModuleDependencyCollector> getModuleDepCollector() const;
522 void setModuleDepCollector(
523 std::shared_ptr<ModuleDependencyCollector> Collector);
525 std::shared_ptr<PCHContainerOperations> getPCHContainerOperations() const {
526 return ThePCHContainerOperations;
529 /// Return the appropriate PCHContainerWriter depending on the
530 /// current CodeGenOptions.
531 const PCHContainerWriter &getPCHContainerWriter() const {
532 assert(Invocation && "cannot determine module format without invocation");
533 StringRef Format = getHeaderSearchOpts().ModuleFormat;
534 auto *Writer = ThePCHContainerOperations->getWriterOrNull(Format);
537 Diagnostics->Report(diag::err_module_format_unhandled) << Format;
538 llvm::report_fatal_error("unknown module format");
543 /// Return the appropriate PCHContainerReader depending on the
544 /// current CodeGenOptions.
545 const PCHContainerReader &getPCHContainerReader() const {
546 assert(Invocation && "cannot determine module format without invocation");
547 StringRef Format = getHeaderSearchOpts().ModuleFormat;
548 auto *Reader = ThePCHContainerOperations->getReaderOrNull(Format);
551 Diagnostics->Report(diag::err_module_format_unhandled) << Format;
552 llvm::report_fatal_error("unknown module format");
558 /// @name Code Completion
561 bool hasCodeCompletionConsumer() const { return (bool)CompletionConsumer; }
563 CodeCompleteConsumer &getCodeCompletionConsumer() const {
564 assert(CompletionConsumer &&
565 "Compiler instance has no code completion consumer!");
566 return *CompletionConsumer;
569 /// setCodeCompletionConsumer - Replace the current code completion consumer;
570 /// the compiler instance takes ownership of \p Value.
571 void setCodeCompletionConsumer(CodeCompleteConsumer *Value);
574 /// @name Frontend timer
577 bool hasFrontendTimer() const { return (bool)FrontendTimer; }
579 llvm::Timer &getFrontendTimer() const {
580 assert(FrontendTimer && "Compiler instance has no frontend timer!");
581 return *FrontendTimer;
585 /// @name Output Files
588 /// addOutputFile - Add an output file onto the list of tracked output files.
590 /// \param OutFile - The output file info.
591 void addOutputFile(OutputFile &&OutFile);
593 /// clearOutputFiles - Clear the output file list. The underlying output
594 /// streams must have been closed beforehand.
596 /// \param EraseFiles - If true, attempt to erase the files from disk.
597 void clearOutputFiles(bool EraseFiles);
600 /// @name Construction Utility Methods
603 /// Create the diagnostics engine using the invocation's diagnostic options
604 /// and replace any existing one with it.
606 /// Note that this routine also replaces the diagnostic client,
607 /// allocating one if one is not provided.
609 /// \param Client If non-NULL, a diagnostic client that will be
610 /// attached to (and, then, owned by) the DiagnosticsEngine inside this AST
613 /// \param ShouldOwnClient If Client is non-NULL, specifies whether
614 /// the diagnostic object should take ownership of the client.
615 void createDiagnostics(DiagnosticConsumer *Client = nullptr,
616 bool ShouldOwnClient = true);
618 /// Create a DiagnosticsEngine object with a the TextDiagnosticPrinter.
620 /// If no diagnostic client is provided, this creates a
621 /// DiagnosticConsumer that is owned by the returned diagnostic
622 /// object, if using directly the caller is responsible for
623 /// releasing the returned DiagnosticsEngine's client eventually.
625 /// \param Opts - The diagnostic options; note that the created text
626 /// diagnostic object contains a reference to these options.
628 /// \param Client If non-NULL, a diagnostic client that will be
629 /// attached to (and, then, owned by) the returned DiagnosticsEngine
632 /// \param CodeGenOpts If non-NULL, the code gen options in use, which may be
633 /// used by some diagnostics printers (for logging purposes only).
635 /// \return The new object on success, or null on failure.
636 static IntrusiveRefCntPtr<DiagnosticsEngine>
637 createDiagnostics(DiagnosticOptions *Opts,
638 DiagnosticConsumer *Client = nullptr,
639 bool ShouldOwnClient = true,
640 const CodeGenOptions *CodeGenOpts = nullptr);
642 /// Create the file manager and replace any existing one with it.
644 /// \return The new file manager on success, or null on failure.
645 FileManager *createFileManager();
647 /// Create the source manager and replace any existing one with it.
648 void createSourceManager(FileManager &FileMgr);
650 /// Create the preprocessor, using the invocation, file, and source managers,
651 /// and replace any existing one with it.
652 void createPreprocessor(TranslationUnitKind TUKind);
654 std::string getSpecificModuleCachePath();
656 /// Create the AST context.
657 void createASTContext();
659 /// Create an external AST source to read a PCH file and attach it to the AST
661 void createPCHExternalASTSource(StringRef Path, bool DisablePCHValidation,
662 bool AllowPCHWithCompilerErrors,
663 void *DeserializationListener,
664 bool OwnDeserializationListener);
666 /// Create an external AST source to read a PCH file.
668 /// \return - The new object on success, or null on failure.
669 static IntrusiveRefCntPtr<ASTReader> createPCHExternalASTSource(
670 StringRef Path, StringRef Sysroot, bool DisablePCHValidation,
671 bool AllowPCHWithCompilerErrors, Preprocessor &PP, ASTContext &Context,
672 const PCHContainerReader &PCHContainerRdr,
673 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
674 DependencyFileGenerator *DependencyFile,
675 ArrayRef<std::shared_ptr<DependencyCollector>> DependencyCollectors,
676 void *DeserializationListener, bool OwnDeserializationListener,
677 bool Preamble, bool UseGlobalModuleIndex);
679 /// Create a code completion consumer using the invocation; note that this
680 /// will cause the source manager to truncate the input source file at the
681 /// completion point.
682 void createCodeCompletionConsumer();
684 /// Create a code completion consumer to print code completion results, at
685 /// \p Filename, \p Line, and \p Column, to the given output stream \p OS.
686 static CodeCompleteConsumer *createCodeCompletionConsumer(
687 Preprocessor &PP, StringRef Filename, unsigned Line, unsigned Column,
688 const CodeCompleteOptions &Opts, raw_ostream &OS);
690 /// \brief Create the Sema object to be used for parsing.
691 void createSema(TranslationUnitKind TUKind,
692 CodeCompleteConsumer *CompletionConsumer);
694 /// Create the frontend timer and replace any existing one with it.
695 void createFrontendTimer();
697 /// Create the default output file (from the invocation's options) and add it
698 /// to the list of tracked output files.
700 /// The files created by this function always use temporary files to write to
701 /// their result (that is, the data is written to a temporary file which will
702 /// atomically replace the target output on success).
704 /// \return - Null on error.
705 std::unique_ptr<raw_pwrite_stream>
706 createDefaultOutputFile(bool Binary = true, StringRef BaseInput = "",
707 StringRef Extension = "");
709 /// Create a new output file and add it to the list of tracked output files,
710 /// optionally deriving the output path name.
712 /// \return - Null on error.
713 std::unique_ptr<raw_pwrite_stream>
714 createOutputFile(StringRef OutputPath, bool Binary, bool RemoveFileOnSignal,
715 StringRef BaseInput, StringRef Extension, bool UseTemporary,
716 bool CreateMissingDirectories = false);
718 /// Create a new output file, optionally deriving the output path name.
720 /// If \p OutputPath is empty, then createOutputFile will derive an output
721 /// path location as \p BaseInput, with any suffix removed, and \p Extension
722 /// appended. If \p OutputPath is not stdout and \p UseTemporary
723 /// is true, createOutputFile will create a new temporary file that must be
724 /// renamed to \p OutputPath in the end.
726 /// \param OutputPath - If given, the path to the output file.
727 /// \param Error [out] - On failure, the error.
728 /// \param BaseInput - If \p OutputPath is empty, the input path name to use
729 /// for deriving the output path.
730 /// \param Extension - The extension to use for derived output names.
731 /// \param Binary - The mode to open the file in.
732 /// \param RemoveFileOnSignal - Whether the file should be registered with
733 /// llvm::sys::RemoveFileOnSignal. Note that this is not safe for
734 /// multithreaded use, as the underlying signal mechanism is not reentrant
735 /// \param UseTemporary - Create a new temporary file that must be renamed to
736 /// OutputPath in the end.
737 /// \param CreateMissingDirectories - When \p UseTemporary is true, create
738 /// missing directories in the output path.
739 /// \param ResultPathName [out] - If given, the result path name will be
740 /// stored here on success.
741 /// \param TempPathName [out] - If given, the temporary file path name
742 /// will be stored here on success.
743 std::unique_ptr<raw_pwrite_stream>
744 createOutputFile(StringRef OutputPath, std::error_code &Error, bool Binary,
745 bool RemoveFileOnSignal, StringRef BaseInput,
746 StringRef Extension, bool UseTemporary,
747 bool CreateMissingDirectories, std::string *ResultPathName,
748 std::string *TempPathName);
750 std::unique_ptr<raw_pwrite_stream> createNullOutputFile();
753 /// @name Initialization Utility Methods
756 /// InitializeSourceManager - Initialize the source manager to set InputFile
757 /// as the main file.
759 /// \return True on success.
760 bool InitializeSourceManager(const FrontendInputFile &Input);
762 /// InitializeSourceManager - Initialize the source manager to set InputFile
763 /// as the main file.
765 /// \return True on success.
766 static bool InitializeSourceManager(const FrontendInputFile &Input,
767 DiagnosticsEngine &Diags,
768 FileManager &FileMgr,
769 SourceManager &SourceMgr,
771 DependencyOutputOptions &DepOpts,
772 const FrontendOptions &Opts);
776 // Create module manager.
777 void createModuleManager();
779 bool loadModuleFile(StringRef FileName);
781 ModuleLoadResult loadModule(SourceLocation ImportLoc, ModuleIdPath Path,
782 Module::NameVisibilityKind Visibility,
783 bool IsInclusionDirective) override;
785 void loadModuleFromSource(SourceLocation ImportLoc, StringRef ModuleName,
786 StringRef Source) override;
788 void makeModuleVisible(Module *Mod, Module::NameVisibilityKind Visibility,
789 SourceLocation ImportLoc) override;
791 bool hadModuleLoaderFatalFailure() const {
792 return ModuleLoader::HadFatalFailure;
795 GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc) override;
797 bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc) override;
799 void addDependencyCollector(std::shared_ptr<DependencyCollector> Listener) {
800 DependencyCollectors.push_back(std::move(Listener));
803 void setExternalSemaSource(IntrusiveRefCntPtr<ExternalSemaSource> ESS);
805 MemoryBufferCache &getPCMCache() const { return *PCMCache; }
808 } // end namespace clang