Lines Matching refs:CI
144 CompilerInstance &CI = getCompilerInstance();
145 return CI.getPreprocessor().getHeaderSearchInfo().lookupModule(
146 CI.getLangOpts().CurrentModule, /*AllowSearch*/false);
150 FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI,
152 std::unique_ptr<ASTConsumer> Consumer = CreateASTConsumer(CI, InFile);
158 for (const std::string &Arg : CI.getFrontendOpts().AddPluginActions) {
166 CI.getDiagnostics().Report(diag::err_fe_invalid_plugin_name) << Arg;
178 if (CI.hasCodeCompletionConsumer())
192 if (llvm::any_of(CI.getFrontendOpts().AddPluginActions,
201 CI,
202 CI.getFrontendOpts().PluginArgs[std::string(Plugin.getName())])) {
203 std::unique_ptr<ASTConsumer> PluginConsumer = P->CreateASTConsumer(CI, InFile);
225 /// \param CI The compiler instance.
230 static SourceLocation ReadOriginalFileName(CompilerInstance &CI,
233 auto &SourceMgr = CI.getSourceManager();
241 new Lexer(MainFileID, *MainFileBuf, SourceMgr, CI.getLangOpts()));
259 if (Lexer::getSpelling(LineNoLoc, Buffer, SourceMgr, CI.getLangOpts())
268 StringLiteralParser Literal(T, CI.getPreprocessor());
277 CI.getSourceManager().AddLineNote(
428 static bool loadModuleMapForModuleBuild(CompilerInstance &CI, bool IsSystem,
432 auto &SrcMgr = CI
433 HeaderSearch &HS = CI.getPreprocessor().getHeaderSearchInfo();
444 ReadOriginalFileName(CI, PresumedModuleMapFile, /*IsModuleMap*/ true);
446 Offset = CI.getSourceManager().getDecomposedLoc(EndOfLineMarker).second;
460 static Module *prepareToBuildModule(CompilerInstance &CI,
462 if (CI.getLangOpts().CurrentModule.empty()) {
463 CI.getDiagnostics().Report(diag::err_missing_module_name);
473 HeaderSearch &HS = CI.getPreprocessor().getHeaderSearchInfo();
474 Module *M = HS.lookupModule(CI.getLangOpts().CurrentModule,
477 CI.getDiagnostics().Report(diag::err_missing_module)
478 << CI.getLangOpts().CurrentModule << ModuleMapFilename;
484 if (Preprocessor::checkModuleIsAvailable(CI.getLangOpts(), CI.getTarget(),
485 CI.getDiagnostics(), M))
490 CI.getPreprocessor().setMainFileDir(M->Directory);
496 StringRef OriginalModuleMapName = CI.getFrontendOpts().OriginalModuleMap;
499 CI.getFileManager().getFile(OriginalModuleMapName,
502 CI.getDiagnostics().Report(diag::err_module_map_not_found)
506 if (*OriginalModuleMap != CI.getSourceManager().getFileEntryForID(
507 CI.getSourceManager().getMainFileID())) {
509 CI.getPreprocessor().getHeaderSearchInfo().getModuleMap()
517 SourceManager &SourceMgr = CI.getSourceManager();
519 SourceMgr.pushModuleBuildStack(CI.getLangOpts().CurrentModule,
526 getInputBufferForModule(CompilerInstance &CI, Module *M) {
527 FileManager &FileMgr = CI.getFileManager();
534 HeaderContents, CI.getLangOpts(), M->IsExternC);
536 CI.getLangOpts(), FileMgr, CI.getDiagnostics(),
537 CI.getPreprocessor().getHeaderSearchInfo().getModuleMap(), M,
541 CI.getDiagnostics().Report(diag::err_module_cannot_create_includes)
550 bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
556 setCompilerInstance(&CI);
561 if (!BeginInvocation(CI))
567 IntrusiveRefCntPtr<DiagnosticsEngine> Diags(&CI.getDiagnostics());
579 std::string(InputFile), CI.getPCHContainerReader(),
580 ASTUnit::LoadPreprocessorOnly, ASTDiags, CI.getFileSystemOpts(),
581 CI.getCodeGenOpts().DebugTypeExtRefs);
587 CI.getHeaderSearchOpts() = AST->getHeaderSearchOpts();
588 CI.getPreprocessorOpts() = AST->getPreprocessorOpts();
589 CI.getLangOpts() = AST->getLangOpts();
593 CI.setFileManager(&AST->getFileManager());
594 CI.createSourceManager(CI.getFileManager());
595 CI.getSourceManager().initializeForReplay(AST->getSourceManager());
606 CI.getFrontendOpts().ModuleFiles.push_back(MF.FileName);
610 CI.getFrontendOpts().ModuleMapFiles.push_back(
641 IntrusiveRefCntPtr<DiagnosticsEngine> Diags(&CI.getDiagnostics());
647 std::string(InputFile), CI.getPCHContainerReader(),
648 ASTUnit::LoadEverything, Diags, CI.getFileSystemOpts(),
649 CI.getCodeGenOpts().DebugTypeExtRefs);
655 CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(), nullptr);
660 CI.setFileManager(&AST->getFileManager());
661 CI.setSourceManager(&AST->getSourceManager());
662 CI.setPreprocessor(AST->getPreprocessorPtr());
663 Preprocessor &PP = CI.getPreprocessor();
666 CI.setASTContext(&AST->getASTContext());
671 if (!BeginSourceFileAction(CI))
675 CI.setASTConsumer(CreateWrappedASTConsumer(CI, InputFile));
676 if (!CI.hasASTConsumer())
683 if (!CI.hasFileManager()) {
684 if (!CI.createFileManager()) {
688 if (!CI.hasSourceManager())
689 CI.createSourceManager(CI.getFileManager());
693 for (const auto &F : CI.getFrontendOpts().ModulesEmbedFiles) {
694 if (auto FE = CI.getFileManager().getFile(F, /*openFile*/true))
695 CI.getSourceManager().setFileIsTransient(*FE);
697 CI.getDiagnostics().Report(diag::err_modules_embed_file_not_found) << F;
699 if (CI.getFrontendOpts().ModulesEmbedAllFiles)
700 CI.getSourceManager().setAllFilesAreTransient(true);
708 CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(), nullptr);
712 if (!BeginSourceFileAction(CI))
716 if (!CI.InitializeSourceManager(CurrentInput))
724 if (!CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
725 FileManager &FileMgr = CI.getFileManager();
726 PreprocessorOptions &PPOpts = CI.getPreprocessorOpts();
728 std::string SpecificModuleCachePath = CI.getSpecificModuleCachePath();
740 Dir->path(), FileMgr, CI.getPCHContainerReader(),
741 CI.getLangOpts(), CI.getTargetOpts(), CI.getPreprocessorOpts(),
750 CI.getDiagnostics().Report(diag::err_fe_no_pch_in_dir) << PCHInclude;
759 CI.createPreprocessor(getTranslationUnitKind());
762 CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(),
763 &CI.getPreprocessor());
767 if (!CI.InitializeSourceManager(Input))
773 CI.getLangOpts().setCompilingModule(LangOptions::CMK_ModuleMap);
777 if (loadModuleMapForModuleBuild(CI, Input.isSystem(),
782 auto *CurrentModule = prepareToBuildModule(CI, Input.getFile());
790 CI.getPreprocessor().setSkipMainFilePreamble(OffsetToContents, true);
793 auto Buffer = getInputBufferForModule(CI, CurrentModule);
799 auto &SourceMgr = CI.getSourceManager();
807 if (!BeginSourceFileAction(CI))
811 for (const auto &Filename : CI.getFrontendOpts().ModuleMapFiles) {
812 if (auto File = CI.getFileManager().getFile(Filename))
813 CI.getPreprocessor().getHeaderSearchInfo().loadModuleMapFile(
816 CI.getDiagnostics().Report(diag::err_module_map_not_found) << Filename;
821 CI.getPreprocessor()
831 CI.createASTContext();
837 ReadOriginalFileName(CI, PresumedInputFile);
840 CreateWrappedASTConsumer(CI, PresumedInputFile);
846 CI
848 if (!CI.getPreprocessorOpts().ChainedIncludes.empty()) {
851 source = createChainedIncludesSource(CI, FinalReader);
854 CI.setASTReader(static_cast<ASTReader *>(FinalReader.get()));
855 CI.getASTContext().setExternalSource(source);
856 } else if (CI.getLangOpts().Modules ||
857 !CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
863 if (CI.getPreprocessorOpts().DumpDeserializedPCHDecls) {
868 if (!CI.getPreprocessorOpts().DeserializedPCHDeclsToErrorOn.empty()) {
870 CI.getASTContext(),
871 CI.getPreprocessorOpts().DeserializedPCHDeclsToErrorOn,
875 if (!CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
876 CI.createPCHExternalASTSource(
877 CI.getPreprocessorOpts().ImplicitPCHInclude,
878 CI.getPreprocessorOpts().DisablePCHOrModuleValidation,
879 CI.getPreprocessorOpts().AllowPCHWithCompilerErrors,
881 if (!CI.getASTContext().getExternalSource())
887 if (CI.getLangOpts().Modules || !CI.hasASTContext() ||
888 !CI.getASTContext().getExternalSource()) {
889 CI.createASTReader();
890 CI.getASTReader()->setDeserializationListener(DeserialListener,
895 CI.setASTConsumer(std::move(Consumer));
896 if (!CI.hasASTConsumer())
902 if (CI.getLangOpts().Modules || !CI.hasASTContext() ||
903 !CI.getASTContext().getExternalSource()) {
904 Preprocessor &PP = CI.getPreprocessor();
910 assert((!CI.getLangOpts().Modules || CI.getASTReader()) &&
916 for (const auto &ModuleFile : CI.getFrontendOpts().ModuleFiles)
917 if (!CI.loadModuleFile(ModuleFile))
922 if (!CI.getFrontendOpts().OverrideRecordLayoutsFile.empty() &&
923 CI.hasASTContext() && !CI.getASTContext().getExternalSource()) {
926 CI.getFrontendOpts().OverrideRecordLayoutsFile));
927 CI.getASTContext().setExternalSource(Override);
936 CI.getDiagnosticClient().EndSourceFile();
937 CI.clearOutputFiles(/*EraseFiles=*/true);
938 CI.getLangOpts().setCompilingModule(LangOptions::CMK_None);
945 CompilerInstance &CI = getCompilerInstance();
947 if (CI.hasFrontendTimer()) {
948 llvm::TimeRegion Timer(CI.getFrontendTimer());
955 if (CI.shouldBuildGlobalModuleIndex() && CI.hasFileManager() &&
956 CI.hasPreprocessor()) {
958 CI.getPreprocessor().getHeaderSearchInfo().getModuleCachePath();
961 CI.getFileManager(), CI.getPCHContainerReader(), Cache)) {
974 CompilerInstance &CI = getCompilerInstance();
977 CI.getDiagnosticClient().EndSourceFile();
980 if (CI.hasPreprocessor())
981 CI.getPreprocessor().EndSourceFile();
989 bool DisableFree = CI.getFrontendOpts().DisableFree;
991 CI.resetAndLeakSema();
992 CI.resetAndLeakASTContext();
993 llvm::BuryPointer(CI.takeASTConsumer().get());
995 CI.setSema(nullptr);
996 CI.setASTContext(nullptr);
997 CI.setASTConsumer(nullptr);
1000 if (CI.getFrontendOpts().ShowStats) {
1002 CI.getPreprocessor().PrintStats();
1003 CI.getPreprocessor().getIdentifierTable().PrintStats();
1004 CI.getPreprocessor().getHeaderSearchInfo().PrintStats();
1005 CI.getSourceManager().PrintStats();
1011 CI.clearOutputFiles(/*EraseFiles=*/shouldEraseOutputFiles());
1015 CI.resetAndLeakPreprocessor();
1016 CI.resetAndLeakSourceManager();
1017 CI.resetAndLeakFileManager();
1020 CI.setPreprocessor(nullptr);
1021 CI.setSourceManager(nullptr);
1022 CI.setFileManager(nullptr);
1028 CI.getLangOpts().setCompilingModule(LangOptions::CMK_None);
1040 CompilerInstance &CI = getCompilerInstance();
1041 if (!CI.hasPreprocessor())
1047 !CI.getFrontendOpts().CodeCompletionAt.FileName.empty())
1048 CI.createCodeCompletionConsumer();
1052 if (CI.hasCodeCompletionConsumer())
1053 CompletionConsumer = &CI.getCodeCompletionConsumer();
1055 if (!CI.hasSema())
1056 CI.createSema(getTranslationUnitKind(), CompletionConsumer);
1058 ParseAST(CI.getSema(), CI.getFrontendOpts().ShowStats,
1059 CI.getFrontendOpts().SkipFunctionBodies);
1065 PreprocessorFrontendAction::CreateASTConsumer(CompilerInstance &CI,
1070 bool WrapperFrontendAction::PrepareToExecuteAction(CompilerInstance &CI) {
1071 return WrappedAction->PrepareToExecuteAction(CI);
1074 WrapperFrontendAction::CreateASTConsumer(CompilerInstance &CI,
1076 return WrappedAction->CreateASTConsumer(CI, InFile);
1078 bool WrapperFrontendAction::BeginInvocation(CompilerInstance &CI) {
1079 return WrappedAction->BeginInvocation(CI);
1081 bool WrapperFrontendAction::BeginSourceFileAction(CompilerInstance &CI) {
1083 WrappedAction->setCompilerInstance(&CI);
1084 auto Ret = WrappedAction->BeginSourceFileAction(CI);