Lines Matching defs:CI
158 CompilerInstance &CI = getCompilerInstance();
159 return CI.getPreprocessor().getHeaderSearchInfo().lookupModule(
160 CI.getLangOpts().CurrentModule, SourceLocation(), /*AllowSearch*/false);
164 FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI,
166 std::unique_ptr<ASTConsumer> Consumer = CreateASTConsumer(CI, InFile);
172 for (const std::string &Arg : CI.getFrontendOpts().AddPluginActions) {
180 CI.getDiagnostics().Report(diag::err_fe_invalid_plugin_name) << Arg;
192 if (CI.hasCodeCompletionConsumer())
207 if (llvm::is_contained(CI.getFrontendOpts().AddPluginActions,
218 CI,
219 CI.getFrontendOpts().PluginArgs[std::string(Plugin.getName())])) {
220 std::unique_ptr<ASTConsumer> PluginConsumer = P->CreateASTConsumer(CI, InFile);
235 CI.getCodeGenOpts().ClearASTBeforeBackend = false;
247 /// \param CI The compiler instance.
252 static SourceLocation ReadOriginalFileName(CompilerInstance &CI,
255 auto &SourceMgr = CI.getSourceManager();
263 new Lexer(MainFileID, *MainFileBuf, SourceMgr, CI.getLangOpts()));
281 if (Lexer::getSpelling(LineNoLoc, Buffer, SourceMgr, CI.getLangOpts())
290 StringLiteralParser Literal(T, CI.getPreprocessor());
299 CI.getSourceManager().AddLineNote(
446 static bool loadModuleMapForModuleBuild(CompilerInstance &CI, bool IsSystem,
450 auto &SrcMgr = CI.getSourceManager();
451 HeaderSearch &HS = CI.getPreprocessor().getHeaderSearchInfo();
463 ReadOriginalFileName(CI, PresumedModuleMapFile, /*IsModuleMap*/ true);
465 Offset = CI.getSourceManager().getDecomposedLoc(EndOfLineMarker).second;
480 CI.getLangOpts().ModuleName + ".framework");
482 CI.getFileManager().getOptionalDirectoryRef(InferredFrameworkPath))
489 static Module *prepareToBuildModule(CompilerInstance &CI,
491 if (CI.getLangOpts().CurrentModule.empty()) {
492 CI.getDiagnostics().Report(diag::err_missing_module_name);
502 HeaderSearch &HS = CI.getPreprocessor().getHeaderSearchInfo();
503 Module *M = HS.lookupModule(CI.getLangOpts().CurrentModule, SourceLocation(),
506 CI.getDiagnostics().Report(diag::err_missing_module)
507 << CI.getLangOpts().CurrentModule << ModuleMapFilename;
513 if (Preprocessor::checkModuleIsAvailable(CI.getLangOpts(), CI.getTarget(), *M,
514 CI.getDiagnostics()))
519 CI.getPreprocessor().setMainFileDir(*M->Directory);
525 StringRef OriginalModuleMapName = CI.getFrontendOpts().OriginalModuleMap;
528 CI.getFileManager().getOptionalFileRef(OriginalModuleMapName,
531 CI.getDiagnostics().Report(diag::err_module_map_not_found)
535 if (*OriginalModuleMap != CI.getSourceManager().getFileEntryRefForID(
536 CI.getSourceManager().getMainFileID())) {
540 FileID OriginalModuleMapFID = CI.getSourceManager().getOrCreateFileID(
542 CI.getPreprocessor()
552 SourceManager &SourceMgr = CI.getSourceManager();
554 SourceMgr.pushModuleBuildStack(CI.getLangOpts().CurrentModule,
561 getInputBufferForModule(CompilerInstance &CI, Module *M) {
562 FileManager &FileMgr = CI.getFileManager();
570 HeaderContents, CI.getLangOpts(), M->IsExternC);
572 CI.getLangOpts(), FileMgr, CI.getDiagnostics(),
573 CI.getPreprocessor().getHeaderSearchInfo().getModuleMap(), M,
577 CI.getDiagnostics().Report(diag::err_module_cannot_create_includes)
586 bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
592 setCompilerInstance(&CI);
602 CI.getDiagnosticClient().EndSourceFile();
603 CI.setASTConsumer(nullptr);
604 CI.clearOutputFiles(/*EraseFiles=*/true);
605 CI.getLangOpts().setCompilingModule(LangOptions::CMK_None);
610 if (!BeginInvocation(CI))
616 IntrusiveRefCntPtr<DiagnosticsEngine> Diags(&CI.getDiagnostics());
628 std::string(InputFile), CI.getPCHContainerReader(),
629 ASTUnit::LoadPreprocessorOnly, ASTDiags, CI.getFileSystemOpts(),
636 CI.getHeaderSearchOpts() = AST->getHeaderSearchOpts();
637 CI.getPreprocessorOpts() = AST->getPreprocessorOpts();
638 CI.getLangOpts() = AST->getLangOpts();
642 CI.setFileManager(&AST->getFileManager());
643 CI.createSourceManager(CI.getFileManager());
644 CI.getSourceManager().initializeForReplay(AST->getSourceManager());
655 CI.getFrontendOpts().ModuleFiles.push_back(MF.FileName);
658 CI.getFrontendOpts().ModuleMapFiles.push_back(
690 IntrusiveRefCntPtr<DiagnosticsEngine> Diags(&CI.getDiagnostics());
696 std::string(InputFile), CI.getPCHContainerReader(),
697 ASTUnit::LoadEverything, Diags, CI.getFileSystemOpts(),
698 CI.getHeaderSearchOptsPtr(), CI.getLangOptsPtr());
704 CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(), nullptr);
709 CI.setFileManager(&AST->getFileManager());
710 CI.setSourceManager(&AST->getSourceManager());
711 CI.setPreprocessor(AST->getPreprocessorPtr());
712 Preprocessor &PP = CI.getPreprocessor();
715 CI.setASTContext(&AST->getASTContext());
720 if (!BeginSourceFileAction(CI))
724 CI.setASTConsumer(CreateWrappedASTConsumer(CI, InputFile));
725 if (!CI.hasASTConsumer())
733 if (!CI.hasFileManager()) {
734 if (!CI.createFileManager()) {
738 if (!CI.hasSourceManager()) {
739 CI.createSourceManager(CI.getFileManager());
740 if (CI.getDiagnosticOpts().getFormat() == DiagnosticOptions::SARIF) {
741 static_cast<SARIFDiagnosticPrinter *>(&CI.getDiagnosticClient())
743 std::make_unique<SarifDocumentWriter>(CI.getSourceManager()));
749 for (const auto &F : CI.getFrontendOpts().ModulesEmbedFiles) {
750 if (auto FE = CI.getFileManager().getOptionalFileRef(F, /*openFile*/true))
751 CI.getSourceManager().setFileIsTransient(*FE);
753 CI.getDiagnostics().Report(diag::err_modules_embed_file_not_found) << F;
755 if (CI.getFrontendOpts().ModulesEmbedAllFiles)
756 CI.getSourceManager().setAllFilesAreTransient(true);
761 CI.getDiagnostics().Report(diag::err_ast_action_on_llvm_ir)
767 CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(), nullptr);
771 if (!BeginSourceFileAction(CI))
775 if (!CI.InitializeSourceManager(CurrentInput))
784 if (!CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
785 FileManager &FileMgr = CI.getFileManager();
786 PreprocessorOptions &PPOpts = CI.getPreprocessorOpts();
788 std::string SpecificModuleCachePath = CI.getSpecificModuleCachePath();
800 Dir->path(), FileMgr, CI.getModuleCache(),
801 CI.getPCHContainerReader(), CI.getLangOpts(),
802 CI.getTargetOpts(), CI.getPreprocessorOpts(),
811 CI.getDiagnostics().Report(diag::err_fe_no_pch_in_dir) << PCHInclude;
820 CI.createPreprocessor(getTranslationUnitKind());
823 CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(),
824 &CI.getPreprocessor());
831 if (CI.getLangOpts().CPlusPlusModules && Input.getKind().isHeaderUnit() &&
836 assert(CI.hasPreprocessor() &&
838 HeaderSearch &HS = CI.getPreprocessor().getHeaderSearchInfo();
840 auto Dir = CI.getFileManager().getOptionalDirectoryRef(".");
850 CI.getDiagnostics().Report(diag::err_module_header_file_not_found)
862 if (CI.getLangOpts().ModuleName.empty())
863 CI.getLangOpts().ModuleName = std::string(FileName);
864 CI.getLangOpts().CurrentModule = CI.getLangOpts().ModuleName;
867 if (!CI.InitializeSourceManager(Input))
870 if (CI.getLangOpts().CPlusPlusModules && Input.getKind().isHeaderUnit() &&
877 ReadOriginalFileName(CI, PresumedInputFile);
880 if (CI.getLangOpts().ModuleName.empty())
881 CI.getLangOpts().ModuleName = std::string(PresumedInputFile);
882 CI.getLangOpts().CurrentModule = CI.getLangOpts().ModuleName;
888 CI.getLangOpts().setCompilingModule(LangOptions::CMK_ModuleMap);
892 if (loadModuleMapForModuleBuild(CI, Input.isSystem(),
897 auto *CurrentModule = prepareToBuildModule(CI, Input.getFile());
905 CI.getPreprocessor().setSkipMainFilePreamble(OffsetToContents, true);
908 auto Buffer = getInputBufferForModule(CI, CurrentModule);
914 auto &SourceMgr = CI.getSourceManager();
922 if (!BeginSourceFileAction(CI))
926 for (const auto &Filename : CI.getFrontendOpts().ModuleMapFiles) {
927 if (auto File = CI.getFileManager().getOptionalFileRef(Filename))
928 CI.getPreprocessor().getHeaderSearchInfo().loadModuleMapFile(
931 CI.getDiagnostics().Report(diag::err_module_map_not_found) << Filename;
935 (void)CI.getPreprocessor().getCurrentModuleImplementation();
939 CI.getPreprocessor()
949 CI.createASTContext();
955 ReadOriginalFileName(CI, PresumedInputFile);
958 CreateWrappedASTConsumer(CI, PresumedInputFile);
964 CI.getASTContext().setASTMutationListener(Consumer->GetASTMutationListener());
966 if (!CI.getPreprocessorOpts().ChainedIncludes.empty()) {
969 source = createChainedIncludesSource(CI, FinalReader);
972 CI.setASTReader(static_cast<ASTReader *>(FinalReader.get()));
973 CI.getASTContext().setExternalSource(source);
974 } else if (CI.getLangOpts().Modules ||
975 !CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
981 if (CI.getPreprocessorOpts().DumpDeserializedPCHDecls) {
986 if (!CI.getPreprocessorOpts().DeserializedPCHDeclsToErrorOn.empty()) {
988 CI.getASTContext(),
989 CI.getPreprocessorOpts().DeserializedPCHDeclsToErrorOn,
993 if (!CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
994 CI.createPCHExternalASTSource(
995 CI.getPreprocessorOpts().ImplicitPCHInclude,
996 CI.getPreprocessorOpts().DisablePCHOrModuleValidation,
997 CI.getPreprocessorOpts().AllowPCHWithCompilerErrors,
999 if (!CI.getASTContext().getExternalSource())
1005 if (CI.getLangOpts().Modules || !CI.hasASTContext() ||
1006 !CI.getASTContext().getExternalSource()) {
1007 CI.createASTReader();
1008 CI.getASTReader()->setDeserializationListener(DeserialListener,
1013 CI.setASTConsumer(std::move(Consumer));
1014 if (!CI.hasASTConsumer())
1020 if (CI.getLangOpts().Modules || !CI.hasASTContext() ||
1021 !CI.getASTContext().getExternalSource()) {
1022 Preprocessor &PP = CI.getPreprocessor();
1028 assert((!CI.getLangOpts().Modules || CI.getASTReader()) &&
1034 for (const auto &ModuleFile : CI.getFrontendOpts().ModuleFiles) {
1036 if (!CI.loadModuleFile(ModuleFile, Loaded))
1040 CI.getDiagnostics().Report(
1046 if (!CI.getFrontendOpts().OverrideRecordLayoutsFile.empty() &&
1047 CI.hasASTContext() && !CI.getASTContext().getExternalSource()) {
1050 CI.getFrontendOpts().OverrideRecordLayoutsFile));
1051 CI.getASTContext().setExternalSource(Override);
1055 if (CI.getLangOpts().HLSL && CI.hasASTContext()) {
1059 CI.getASTContext().getExternalSource())) {
1062 CI.getASTContext().setExternalSource(MultiSema);
1064 CI.getASTContext().setExternalSource(HLSLSema);
1072 CompilerInstance &CI = getCompilerInstance();
1074 if (CI.hasFrontendTimer()) {
1075 llvm::TimeRegion Timer(CI.getFrontendTimer());
1082 if (CI.shouldBuildGlobalModuleIndex() && CI.hasFileManager() &&
1083 CI.hasPreprocessor()) {
1085 CI.getPreprocessor().getHeaderSearchInfo().getModuleCachePath();
1088 CI.getFileManager(), CI.getPCHContainerReader(), Cache)) {
1101 CompilerInstance &CI = getCompilerInstance();
1104 CI.getDiagnosticClient().EndSourceFile();
1107 if (CI.hasPreprocessor())
1108 CI.getPreprocessor().EndSourceFile();
1116 bool DisableFree = CI.getFrontendOpts().DisableFree;
1118 CI.resetAndLeakSema();
1119 CI.resetAndLeakASTContext();
1120 llvm::BuryPointer(CI.takeASTConsumer().get());
1122 CI.setSema(nullptr);
1123 CI.setASTContext(nullptr);
1124 CI.setASTConsumer(nullptr);
1127 if (CI.getFrontendOpts().ShowStats) {
1129 CI.getPreprocessor().PrintStats();
1130 CI.getPreprocessor().getIdentifierTable().PrintStats();
1131 CI.getPreprocessor().getHeaderSearchInfo().PrintStats();
1132 CI.getSourceManager().PrintStats();
1138 CI.clearOutputFiles(/*EraseFiles=*/shouldEraseOutputFiles());
1145 CI.resetAndLeakPreprocessor();
1146 CI.resetAndLeakSourceManager();
1147 CI.resetAndLeakFileManager();
1150 CI.setPreprocessor(nullptr);
1151 CI.setSourceManager(nullptr);
1152 CI.setFileManager(nullptr);
1158 CI.getLangOpts().setCompilingModule(LangOptions::CMK_None);
1170 CompilerInstance &CI = getCompilerInstance();
1171 if (!CI.hasPreprocessor())
1181 !CI.getFrontendOpts().CodeCompletionAt.FileName.empty())
1182 CI.createCodeCompletionConsumer();
1186 if (CI.hasCodeCompletionConsumer())
1187 CompletionConsumer = &CI.getCodeCompletionConsumer();
1189 if (!CI.hasSema())
1190 CI.createSema(getTranslationUnitKind(), CompletionConsumer);
1192 ParseAST(CI.getSema(), CI.getFrontendOpts().ShowStats,
1193 CI.getFrontendOpts().SkipFunctionBodies);
1199 PreprocessorFrontendAction::CreateASTConsumer(CompilerInstance &CI,
1204 bool WrapperFrontendAction::PrepareToExecuteAction(CompilerInstance &CI) {
1205 return WrappedAction->PrepareToExecuteAction(CI);
1208 WrapperFrontendAction::CreateASTConsumer(CompilerInstance &CI,
1210 return WrappedAction->CreateASTConsumer(CI, InFile);
1212 bool WrapperFrontendAction::BeginInvocation(CompilerInstance &CI) {
1213 return WrappedAction->BeginInvocation(CI);
1215 bool WrapperFrontendAction::BeginSourceFileAction(CompilerInstance &CI) {
1217 WrappedAction->setCompilerInstance(&CI);
1218 auto Ret = WrappedAction->BeginSourceFileAction(CI);