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"
25 #include "llvm/Support/BuryPointer.h"
41 class CodeCompleteConsumer;
42 class DiagnosticsEngine;
43 class DiagnosticConsumer;
44 class ExternalASTSource;
48 class MemoryBufferCache;
55 /// CompilerInstance - Helper class for managing a single instance of the Clang
58 /// The CompilerInstance serves two purposes:
59 /// (1) It manages the various objects which are necessary to run the compiler,
60 /// for example the preprocessor, the target information, and the AST
62 /// (2) It provides utility routines for constructing and manipulating the
63 /// common Clang objects.
65 /// The compiler instance generally owns the instance of all the objects that it
66 /// manages. However, clients can still share objects by manually setting the
67 /// object and retaking ownership prior to destroying the CompilerInstance.
69 /// The compiler instance is intended to simplify clients, but not to lock them
70 /// in to the compiler instance for everything. When possible, utility functions
71 /// come in two forms; a short form that reuses the CompilerInstance objects,
72 /// and a long form that takes explicit instances of any required objects.
73 class CompilerInstance : public ModuleLoader {
74 /// The options used in this compiler instance.
75 std::shared_ptr<CompilerInvocation> Invocation;
77 /// The diagnostics engine instance.
78 IntrusiveRefCntPtr<DiagnosticsEngine> Diagnostics;
80 /// The target being compiled for.
81 IntrusiveRefCntPtr<TargetInfo> Target;
83 /// Auxiliary Target info.
84 IntrusiveRefCntPtr<TargetInfo> AuxTarget;
86 /// The virtual file system.
87 IntrusiveRefCntPtr<llvm::vfs::FileSystem> VirtualFileSystem;
90 IntrusiveRefCntPtr<FileManager> FileMgr;
92 /// The source manager.
93 IntrusiveRefCntPtr<SourceManager> SourceMgr;
95 /// The cache of PCM files.
96 IntrusiveRefCntPtr<MemoryBufferCache> PCMCache;
99 std::shared_ptr<Preprocessor> PP;
102 IntrusiveRefCntPtr<ASTContext> Context;
104 /// An optional sema source that will be attached to sema.
105 IntrusiveRefCntPtr<ExternalSemaSource> ExternalSemaSrc;
107 /// The AST consumer.
108 std::unique_ptr<ASTConsumer> Consumer;
110 /// The code completion consumer.
111 std::unique_ptr<CodeCompleteConsumer> CompletionConsumer;
113 /// The semantic analysis object.
114 std::unique_ptr<Sema> TheSema;
116 /// The frontend timer group.
117 std::unique_ptr<llvm::TimerGroup> FrontendTimerGroup;
119 /// The frontend timer.
120 std::unique_ptr<llvm::Timer> FrontendTimer;
122 /// The ASTReader, if one exists.
123 IntrusiveRefCntPtr<ASTReader> ModuleManager;
125 /// The module dependency collector for crashdumps
126 std::shared_ptr<ModuleDependencyCollector> ModuleDepCollector;
128 /// The module provider.
129 std::shared_ptr<PCHContainerOperations> ThePCHContainerOperations;
131 /// The dependency file generator.
132 std::unique_ptr<DependencyFileGenerator> TheDependencyFileGenerator;
134 std::vector<std::shared_ptr<DependencyCollector>> DependencyCollectors;
136 /// The set of top-level modules that has already been loaded,
137 /// along with the module map
138 llvm::DenseMap<const IdentifierInfo *, Module *> KnownModules;
140 /// The set of top-level modules that has already been built on the
141 /// fly as part of this overall compilation action.
142 std::map<std::string, std::string> BuiltModules;
144 /// Should we delete the BuiltModules when we're done?
145 bool DeleteBuiltModules = true;
147 /// The location of the module-import keyword for the last module
149 SourceLocation LastModuleImportLoc;
151 /// The result of the last module import.
153 ModuleLoadResult LastModuleImportResult;
155 /// Whether we should (re)build the global module index once we
156 /// have finished with this translation unit.
157 bool BuildGlobalModuleIndex = false;
159 /// We have a full global module index, with all modules.
160 bool HaveFullGlobalModuleIndex = false;
162 /// One or more modules failed to build.
163 bool ModuleBuildFailed = false;
165 /// Holds information about the output file.
167 /// If TempFilename is not empty we must rename it to Filename at the end.
168 /// TempFilename may be empty and Filename non-empty if creating the temporary
171 std::string Filename;
172 std::string TempFilename;
174 OutputFile(std::string filename, std::string tempFilename)
175 : Filename(std::move(filename)), TempFilename(std::move(tempFilename)) {
179 /// If the output doesn't support seeking (terminal, pipe). we switch
180 /// the stream to a buffer_ostream. These are the buffer and the original
182 std::unique_ptr<llvm::raw_fd_ostream> NonSeekStream;
184 /// The list of active output files.
185 std::list<OutputFile> OutputFiles;
187 /// Force an output buffer.
188 std::unique_ptr<llvm::raw_pwrite_stream> OutputStream;
190 CompilerInstance(const CompilerInstance &) = delete;
191 void operator=(const CompilerInstance &) = delete;
193 explicit CompilerInstance(
194 std::shared_ptr<PCHContainerOperations> PCHContainerOps =
195 std::make_shared<PCHContainerOperations>(),
196 MemoryBufferCache *SharedPCMCache = nullptr);
197 ~CompilerInstance() override;
199 /// @name High-Level Operations
202 /// ExecuteAction - Execute the provided action against the compiler's
203 /// CompilerInvocation object.
205 /// This function makes the following assumptions:
207 /// - The invocation options should be initialized. This function does not
208 /// handle the '-help' or '-version' options, clients should handle those
211 /// - The diagnostics engine should have already been created by the client.
213 /// - No other CompilerInstance state should have been initialized (this is
214 /// an unchecked error).
216 /// - Clients should have initialized any LLVM target features that may be
219 /// - Clients should eventually call llvm_shutdown() upon the completion of
220 /// this routine to ensure that any managed objects are properly destroyed.
222 /// Note that this routine may write output to 'stderr'.
224 /// \param Act - The action to execute.
225 /// \return - True on success.
227 // FIXME: This function should take the stream to write any debugging /
228 // verbose output to as an argument.
230 // FIXME: Eliminate the llvm_shutdown requirement, that should either be part
231 // of the context or else not CompilerInstance specific.
232 bool ExecuteAction(FrontendAction &Act);
235 /// @name Compiler Invocation and Options
238 bool hasInvocation() const { return Invocation != nullptr; }
240 CompilerInvocation &getInvocation() {
241 assert(Invocation && "Compiler instance has no invocation!");
245 /// setInvocation - Replace the current invocation.
246 void setInvocation(std::shared_ptr<CompilerInvocation> Value);
248 /// Indicates whether we should (re)build the global module index.
249 bool shouldBuildGlobalModuleIndex() const;
251 /// Set the flag indicating whether we should (re)build the global
253 void setBuildGlobalModuleIndex(bool Build) {
254 BuildGlobalModuleIndex = Build;
258 /// @name Forwarding Methods
261 AnalyzerOptionsRef getAnalyzerOpts() {
262 return Invocation->getAnalyzerOpts();
265 CodeGenOptions &getCodeGenOpts() {
266 return Invocation->getCodeGenOpts();
268 const CodeGenOptions &getCodeGenOpts() const {
269 return Invocation->getCodeGenOpts();
272 DependencyOutputOptions &getDependencyOutputOpts() {
273 return Invocation->getDependencyOutputOpts();
275 const DependencyOutputOptions &getDependencyOutputOpts() const {
276 return Invocation->getDependencyOutputOpts();
279 DiagnosticOptions &getDiagnosticOpts() {
280 return Invocation->getDiagnosticOpts();
282 const DiagnosticOptions &getDiagnosticOpts() const {
283 return Invocation->getDiagnosticOpts();
286 FileSystemOptions &getFileSystemOpts() {
287 return Invocation->getFileSystemOpts();
289 const FileSystemOptions &getFileSystemOpts() const {
290 return Invocation->getFileSystemOpts();
293 FrontendOptions &getFrontendOpts() {
294 return Invocation->getFrontendOpts();
296 const FrontendOptions &getFrontendOpts() const {
297 return Invocation->getFrontendOpts();
300 HeaderSearchOptions &getHeaderSearchOpts() {
301 return Invocation->getHeaderSearchOpts();
303 const HeaderSearchOptions &getHeaderSearchOpts() const {
304 return Invocation->getHeaderSearchOpts();
306 std::shared_ptr<HeaderSearchOptions> getHeaderSearchOptsPtr() const {
307 return Invocation->getHeaderSearchOptsPtr();
310 LangOptions &getLangOpts() {
311 return *Invocation->getLangOpts();
313 const LangOptions &getLangOpts() const {
314 return *Invocation->getLangOpts();
317 PreprocessorOptions &getPreprocessorOpts() {
318 return Invocation->getPreprocessorOpts();
320 const PreprocessorOptions &getPreprocessorOpts() const {
321 return Invocation->getPreprocessorOpts();
324 PreprocessorOutputOptions &getPreprocessorOutputOpts() {
325 return Invocation->getPreprocessorOutputOpts();
327 const PreprocessorOutputOptions &getPreprocessorOutputOpts() const {
328 return Invocation->getPreprocessorOutputOpts();
331 TargetOptions &getTargetOpts() {
332 return Invocation->getTargetOpts();
334 const TargetOptions &getTargetOpts() const {
335 return Invocation->getTargetOpts();
339 /// @name Diagnostics Engine
342 bool hasDiagnostics() const { return Diagnostics != nullptr; }
344 /// Get the current diagnostics engine.
345 DiagnosticsEngine &getDiagnostics() const {
346 assert(Diagnostics && "Compiler instance has no diagnostics!");
350 /// setDiagnostics - Replace the current diagnostics engine.
351 void setDiagnostics(DiagnosticsEngine *Value);
353 DiagnosticConsumer &getDiagnosticClient() const {
354 assert(Diagnostics && Diagnostics->getClient() &&
355 "Compiler instance has no diagnostic client!");
356 return *Diagnostics->getClient();
360 /// @name Target Info
363 bool hasTarget() const { return Target != nullptr; }
365 TargetInfo &getTarget() const {
366 assert(Target && "Compiler instance has no target!");
370 /// Replace the current Target.
371 void setTarget(TargetInfo *Value);
374 /// @name AuxTarget Info
377 TargetInfo *getAuxTarget() const { return AuxTarget.get(); }
379 /// Replace the current AuxTarget.
380 void setAuxTarget(TargetInfo *Value);
383 /// @name Virtual File System
386 bool hasVirtualFileSystem() const { return VirtualFileSystem != nullptr; }
388 llvm::vfs::FileSystem &getVirtualFileSystem() const {
389 assert(hasVirtualFileSystem() &&
390 "Compiler instance has no virtual file system");
391 return *VirtualFileSystem;
394 /// Replace the current virtual file system.
396 /// \note Most clients should use setFileManager, which will implicitly reset
397 /// the virtual file system to the one contained in the file manager.
398 void setVirtualFileSystem(IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS) {
399 VirtualFileSystem = std::move(FS);
403 /// @name File Manager
406 bool hasFileManager() const { return FileMgr != nullptr; }
408 /// Return the current file manager to the caller.
409 FileManager &getFileManager() const {
410 assert(FileMgr && "Compiler instance has no file manager!");
414 void resetAndLeakFileManager() {
415 llvm::BuryPointer(FileMgr.get());
416 FileMgr.resetWithoutRelease();
419 /// Replace the current file manager and virtual file system.
420 void setFileManager(FileManager *Value);
423 /// @name Source Manager
426 bool hasSourceManager() const { return SourceMgr != nullptr; }
428 /// Return the current source manager.
429 SourceManager &getSourceManager() const {
430 assert(SourceMgr && "Compiler instance has no source manager!");
434 void resetAndLeakSourceManager() {
435 llvm::BuryPointer(SourceMgr.get());
436 SourceMgr.resetWithoutRelease();
439 /// setSourceManager - Replace the current source manager.
440 void setSourceManager(SourceManager *Value);
443 /// @name Preprocessor
446 bool hasPreprocessor() const { return PP != nullptr; }
448 /// Return the current preprocessor.
449 Preprocessor &getPreprocessor() const {
450 assert(PP && "Compiler instance has no preprocessor!");
454 std::shared_ptr<Preprocessor> getPreprocessorPtr() { return PP; }
456 void resetAndLeakPreprocessor() {
457 llvm::BuryPointer(new std::shared_ptr<Preprocessor>(PP));
460 /// Replace the current preprocessor.
461 void setPreprocessor(std::shared_ptr<Preprocessor> Value);
467 bool hasASTContext() const { return Context != nullptr; }
469 ASTContext &getASTContext() const {
470 assert(Context && "Compiler instance has no AST context!");
474 void resetAndLeakASTContext() {
475 llvm::BuryPointer(Context.get());
476 Context.resetWithoutRelease();
479 /// setASTContext - Replace the current AST context.
480 void setASTContext(ASTContext *Value);
482 /// Replace the current Sema; the compiler instance takes ownership
484 void setSema(Sema *S);
487 /// @name ASTConsumer
490 bool hasASTConsumer() const { return (bool)Consumer; }
492 ASTConsumer &getASTConsumer() const {
493 assert(Consumer && "Compiler instance has no AST consumer!");
497 /// takeASTConsumer - Remove the current AST consumer and give ownership to
499 std::unique_ptr<ASTConsumer> takeASTConsumer() { return std::move(Consumer); }
501 /// setASTConsumer - Replace the current AST consumer; the compiler instance
502 /// takes ownership of \p Value.
503 void setASTConsumer(std::unique_ptr<ASTConsumer> Value);
506 /// @name Semantic analysis
508 bool hasSema() const { return (bool)TheSema; }
510 Sema &getSema() const {
511 assert(TheSema && "Compiler instance has no Sema object!");
515 std::unique_ptr<Sema> takeSema();
516 void resetAndLeakSema();
519 /// @name Module Management
522 IntrusiveRefCntPtr<ASTReader> getModuleManager() const;
523 void setModuleManager(IntrusiveRefCntPtr<ASTReader> Reader);
525 std::shared_ptr<ModuleDependencyCollector> getModuleDepCollector() const;
526 void setModuleDepCollector(
527 std::shared_ptr<ModuleDependencyCollector> Collector);
529 std::shared_ptr<PCHContainerOperations> getPCHContainerOperations() const {
530 return ThePCHContainerOperations;
533 /// Return the appropriate PCHContainerWriter depending on the
534 /// current CodeGenOptions.
535 const PCHContainerWriter &getPCHContainerWriter() const {
536 assert(Invocation && "cannot determine module format without invocation");
537 StringRef Format = getHeaderSearchOpts().ModuleFormat;
538 auto *Writer = ThePCHContainerOperations->getWriterOrNull(Format);
541 Diagnostics->Report(diag::err_module_format_unhandled) << Format;
542 llvm::report_fatal_error("unknown module format");
547 /// Return the appropriate PCHContainerReader depending on the
548 /// current CodeGenOptions.
549 const PCHContainerReader &getPCHContainerReader() const {
550 assert(Invocation && "cannot determine module format without invocation");
551 StringRef Format = getHeaderSearchOpts().ModuleFormat;
552 auto *Reader = ThePCHContainerOperations->getReaderOrNull(Format);
555 Diagnostics->Report(diag::err_module_format_unhandled) << Format;
556 llvm::report_fatal_error("unknown module format");
562 /// @name Code Completion
565 bool hasCodeCompletionConsumer() const { return (bool)CompletionConsumer; }
567 CodeCompleteConsumer &getCodeCompletionConsumer() const {
568 assert(CompletionConsumer &&
569 "Compiler instance has no code completion consumer!");
570 return *CompletionConsumer;
573 /// setCodeCompletionConsumer - Replace the current code completion consumer;
574 /// the compiler instance takes ownership of \p Value.
575 void setCodeCompletionConsumer(CodeCompleteConsumer *Value);
578 /// @name Frontend timer
581 bool hasFrontendTimer() const { return (bool)FrontendTimer; }
583 llvm::Timer &getFrontendTimer() const {
584 assert(FrontendTimer && "Compiler instance has no frontend timer!");
585 return *FrontendTimer;
589 /// @name Output Files
592 /// addOutputFile - Add an output file onto the list of tracked output files.
594 /// \param OutFile - The output file info.
595 void addOutputFile(OutputFile &&OutFile);
597 /// clearOutputFiles - Clear the output file list. The underlying output
598 /// streams must have been closed beforehand.
600 /// \param EraseFiles - If true, attempt to erase the files from disk.
601 void clearOutputFiles(bool EraseFiles);
604 /// @name Construction Utility Methods
607 /// Create the diagnostics engine using the invocation's diagnostic options
608 /// and replace any existing one with it.
610 /// Note that this routine also replaces the diagnostic client,
611 /// allocating one if one is not provided.
613 /// \param Client If non-NULL, a diagnostic client that will be
614 /// attached to (and, then, owned by) the DiagnosticsEngine inside this AST
617 /// \param ShouldOwnClient If Client is non-NULL, specifies whether
618 /// the diagnostic object should take ownership of the client.
619 void createDiagnostics(DiagnosticConsumer *Client = nullptr,
620 bool ShouldOwnClient = true);
622 /// Create a DiagnosticsEngine object with a the TextDiagnosticPrinter.
624 /// If no diagnostic client is provided, this creates a
625 /// DiagnosticConsumer that is owned by the returned diagnostic
626 /// object, if using directly the caller is responsible for
627 /// releasing the returned DiagnosticsEngine's client eventually.
629 /// \param Opts - The diagnostic options; note that the created text
630 /// diagnostic object contains a reference to these options.
632 /// \param Client If non-NULL, a diagnostic client that will be
633 /// attached to (and, then, owned by) the returned DiagnosticsEngine
636 /// \param CodeGenOpts If non-NULL, the code gen options in use, which may be
637 /// used by some diagnostics printers (for logging purposes only).
639 /// \return The new object on success, or null on failure.
640 static IntrusiveRefCntPtr<DiagnosticsEngine>
641 createDiagnostics(DiagnosticOptions *Opts,
642 DiagnosticConsumer *Client = nullptr,
643 bool ShouldOwnClient = true,
644 const CodeGenOptions *CodeGenOpts = nullptr);
646 /// Create the file manager and replace any existing one with it.
648 /// \return The new file manager on success, or null on failure.
649 FileManager *createFileManager();
651 /// Create the source manager and replace any existing one with it.
652 void createSourceManager(FileManager &FileMgr);
654 /// Create the preprocessor, using the invocation, file, and source managers,
655 /// and replace any existing one with it.
656 void createPreprocessor(TranslationUnitKind TUKind);
658 std::string getSpecificModuleCachePath();
660 /// Create the AST context.
661 void createASTContext();
663 /// Create an external AST source to read a PCH file and attach it to the AST
665 void createPCHExternalASTSource(StringRef Path, bool DisablePCHValidation,
666 bool AllowPCHWithCompilerErrors,
667 void *DeserializationListener,
668 bool OwnDeserializationListener);
670 /// Create an external AST source to read a PCH file.
672 /// \return - The new object on success, or null on failure.
673 static IntrusiveRefCntPtr<ASTReader> createPCHExternalASTSource(
674 StringRef Path, StringRef Sysroot, bool DisablePCHValidation,
675 bool AllowPCHWithCompilerErrors, Preprocessor &PP, ASTContext &Context,
676 const PCHContainerReader &PCHContainerRdr,
677 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
678 DependencyFileGenerator *DependencyFile,
679 ArrayRef<std::shared_ptr<DependencyCollector>> DependencyCollectors,
680 void *DeserializationListener, bool OwnDeserializationListener,
681 bool Preamble, bool UseGlobalModuleIndex);
683 /// Create a code completion consumer using the invocation; note that this
684 /// will cause the source manager to truncate the input source file at the
685 /// completion point.
686 void createCodeCompletionConsumer();
688 /// Create a code completion consumer to print code completion results, at
689 /// \p Filename, \p Line, and \p Column, to the given output stream \p OS.
690 static CodeCompleteConsumer *createCodeCompletionConsumer(
691 Preprocessor &PP, StringRef Filename, unsigned Line, unsigned Column,
692 const CodeCompleteOptions &Opts, raw_ostream &OS);
694 /// Create the Sema object to be used for parsing.
695 void createSema(TranslationUnitKind TUKind,
696 CodeCompleteConsumer *CompletionConsumer);
698 /// Create the frontend timer and replace any existing one with it.
699 void createFrontendTimer();
701 /// Create the default output file (from the invocation's options) and add it
702 /// to the list of tracked output files.
704 /// The files created by this function always use temporary files to write to
705 /// their result (that is, the data is written to a temporary file which will
706 /// atomically replace the target output on success).
708 /// \return - Null on error.
709 std::unique_ptr<raw_pwrite_stream>
710 createDefaultOutputFile(bool Binary = true, StringRef BaseInput = "",
711 StringRef Extension = "");
713 /// Create a new output file and add it to the list of tracked output files,
714 /// optionally deriving the output path name.
716 /// \return - Null on error.
717 std::unique_ptr<raw_pwrite_stream>
718 createOutputFile(StringRef OutputPath, bool Binary, bool RemoveFileOnSignal,
719 StringRef BaseInput, StringRef Extension, bool UseTemporary,
720 bool CreateMissingDirectories = false);
722 /// Create a new output file, optionally deriving the output path name.
724 /// If \p OutputPath is empty, then createOutputFile will derive an output
725 /// path location as \p BaseInput, with any suffix removed, and \p Extension
726 /// appended. If \p OutputPath is not stdout and \p UseTemporary
727 /// is true, createOutputFile will create a new temporary file that must be
728 /// renamed to \p OutputPath in the end.
730 /// \param OutputPath - If given, the path to the output file.
731 /// \param Error [out] - On failure, the error.
732 /// \param BaseInput - If \p OutputPath is empty, the input path name to use
733 /// for deriving the output path.
734 /// \param Extension - The extension to use for derived output names.
735 /// \param Binary - The mode to open the file in.
736 /// \param RemoveFileOnSignal - Whether the file should be registered with
737 /// llvm::sys::RemoveFileOnSignal. Note that this is not safe for
738 /// multithreaded use, as the underlying signal mechanism is not reentrant
739 /// \param UseTemporary - Create a new temporary file that must be renamed to
740 /// OutputPath in the end.
741 /// \param CreateMissingDirectories - When \p UseTemporary is true, create
742 /// missing directories in the output path.
743 /// \param ResultPathName [out] - If given, the result path name will be
744 /// stored here on success.
745 /// \param TempPathName [out] - If given, the temporary file path name
746 /// will be stored here on success.
747 std::unique_ptr<raw_pwrite_stream>
748 createOutputFile(StringRef OutputPath, std::error_code &Error, bool Binary,
749 bool RemoveFileOnSignal, StringRef BaseInput,
750 StringRef Extension, bool UseTemporary,
751 bool CreateMissingDirectories, std::string *ResultPathName,
752 std::string *TempPathName);
754 std::unique_ptr<raw_pwrite_stream> createNullOutputFile();
757 /// @name Initialization Utility Methods
760 /// InitializeSourceManager - Initialize the source manager to set InputFile
761 /// as the main file.
763 /// \return True on success.
764 bool InitializeSourceManager(const FrontendInputFile &Input);
766 /// InitializeSourceManager - Initialize the source manager to set InputFile
767 /// as the main file.
769 /// \return True on success.
770 static bool InitializeSourceManager(const FrontendInputFile &Input,
771 DiagnosticsEngine &Diags,
772 FileManager &FileMgr,
773 SourceManager &SourceMgr,
775 DependencyOutputOptions &DepOpts,
776 const FrontendOptions &Opts);
780 void setOutputStream(std::unique_ptr<llvm::raw_pwrite_stream> OutStream) {
781 OutputStream = std::move(OutStream);
784 std::unique_ptr<llvm::raw_pwrite_stream> takeOutputStream() {
785 return std::move(OutputStream);
788 // Create module manager.
789 void createModuleManager();
791 bool loadModuleFile(StringRef FileName);
793 ModuleLoadResult loadModule(SourceLocation ImportLoc, ModuleIdPath Path,
794 Module::NameVisibilityKind Visibility,
795 bool IsInclusionDirective) override;
797 void loadModuleFromSource(SourceLocation ImportLoc, StringRef ModuleName,
798 StringRef Source) override;
800 void makeModuleVisible(Module *Mod, Module::NameVisibilityKind Visibility,
801 SourceLocation ImportLoc) override;
803 bool hadModuleLoaderFatalFailure() const {
804 return ModuleLoader::HadFatalFailure;
807 GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc) override;
809 bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc) override;
811 void addDependencyCollector(std::shared_ptr<DependencyCollector> Listener) {
812 DependencyCollectors.push_back(std::move(Listener));
815 void setExternalSemaSource(IntrusiveRefCntPtr<ExternalSemaSource> ESS);
817 MemoryBufferCache &getPCMCache() const { return *PCMCache; }
820 } // end namespace clang