@@ -966,16 +966,21 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
966966 }
967967 }
968968
969- bool ProcessesSummaries = !CI.getFrontendOpts ().SummaryDirPath .empty () ||
970- !CI.getFrontendOpts ().SummaryFile .empty ();
971- if (ProcessesSummaries && !CI.hasSummaryContext ())
972- CI.createSummaryContext ();
969+ bool EmitSummaries = !CI.getFrontendOpts ().EmitSummaryDir .empty ();
970+ bool ReadSummaries = !CI.getFrontendOpts ().ReadSummaryDir .empty ();
973971
974- if (ProcessesSummaries && !CI.hasSummarySerializer ())
975- CI.createSummarySerializer ();
972+ if (EmitSummaries || ReadSummaries) {
973+ if (!CI.hasSummaryContext ())
974+ CI.createSummaryContext ();
976975
977- // FIXME: cleanup and lookup dirs recursively
978- if (!CI.getFrontendOpts ().SummaryDirPath .empty ()) {
976+ if (!CI.hasSummarySerializer ())
977+ CI.createSummarySerializer ();
978+ }
979+
980+ if (EmitSummaries)
981+ CI.createSummaryConsumer (getCurrentInput ());
982+
983+ if (ReadSummaries) {
979984 // FIXME: this is a quick shortcut so large summaries are only evaluated
980985 // once, we should think about implementing it in a reasonable way...
981986 static const char *reducedCacheName =
@@ -984,7 +989,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
984989 ' .' + CI.getFrontendOpts ().SummaryFormat ;
985990
986991 FileManager &FileMgr = CI.getFileManager ();
987- StringRef SummaryDirPath = CI.getFrontendOpts ().SummaryDirPath ;
992+ StringRef SummaryDirPath = CI.getFrontendOpts ().ReadSummaryDir ;
988993 if (auto SummaryDir = FileMgr.getOptionalDirectoryRef (SummaryDirPath)) {
989994 std::error_code EC;
990995 SmallString<128 > DirNative;
@@ -1017,13 +1022,13 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
10171022 CI.getSummarySerializer ().parse (buffer.str ());
10181023 }
10191024
1020- CI.getSummaryContext (). ReduceSummaries ();
1025+ CI.getSummaryContext ()-> ReduceSummaries ();
10211026
10221027 if (!FS.exists (cacheFile)) {
10231028 // FIXME: very quick printing of the summary to the cache file
10241029 llvm::raw_fd_ostream fd (cacheFile, EC, llvm::sys::fs::CD_CreateAlways);
10251030 CI.getSummarySerializer ().serialize (
1026- CI.getSummaryContext (). FunctionSummaries , fd);
1031+ CI.getSummaryContext ()-> FunctionSummaries , fd);
10271032 }
10281033 }
10291034 }
@@ -1399,17 +1404,8 @@ void ASTFrontendAction::ExecuteAction() {
13991404 if (CI.hasCodeCompletionConsumer ())
14001405 CompletionConsumer = &CI.getCodeCompletionConsumer ();
14011406
1402- if (!CI.getFrontendOpts ().SummaryFile .empty ())
1403- CI.createSummaryConsumer ();
1404-
1405- // Use a code summary consumer?
1406- SummaryConsumer *SummaryConsumer = nullptr ;
1407- if (CI.hasSummaryConsumer ())
1408- SummaryConsumer = &CI.getSummaryConsumer ();
1409-
14101407 if (!CI.hasSema ())
1411- CI.createSema (getTranslationUnitKind (), CompletionConsumer,
1412- SummaryConsumer);
1408+ CI.createSema (getTranslationUnitKind (), CompletionConsumer);
14131409
14141410 ParseAST (CI.getSema (), CI.getFrontendOpts ().ShowStats ,
14151411 CI.getFrontendOpts ().SkipFunctionBodies );
0 commit comments