@@ -519,70 +519,41 @@ class IDETypeStateAnalysis
519519 void emitTextReport (const SolverResults<n_t , d_t , l_t > &SR,
520520 llvm::raw_ostream &OS = llvm::outs()) override {
521521 LLVMBasedCFG CFG;
522- OS << " \n ======= TYPE STATE RESULTS =======\n " ;
523522 for (const auto &F : this ->IRDB ->getAllFunctions ()) {
524- OS << ' \n ' << F->getName () << ' \n ' ;
525523 for (const auto &BB : *F) {
526524 for (const auto &I : BB) {
527525 auto Results = SR.resultsAt (&I, true );
526+
528527 if (CFG.isExitInst (&I)) {
529- OS << " \n At exit stmt: " << NToString (&I) << ' \n ' ;
530528 for (auto Res : Results) {
531529 if (const auto *Alloca =
532530 llvm::dyn_cast<llvm::AllocaInst>(Res.first )) {
533531 if (Res.second == TSD->error ()) {
534- OS << " \n === ERROR STATE DETECTED ===\n Alloca: "
535- << DToString (Res.first ) << ' \n ' ;
536- for (const auto *Pred : CFG.getPredsOf (&I)) {
537- OS << " \n Predecessor: " << NToString (Pred) << ' \n ' ;
538- auto PredResults = SR.resultsAt (Pred, true );
539- for (auto Res : PredResults) {
540- if (Res.first == Alloca) {
541- OS << " Pred State: " << LToString (Res.second ) << ' \n ' ;
542- }
543- }
544- }
545- OS << " ============================\n " ;
546- } else {
547- OS << " \n Alloca : " << DToString (Res.first )
548- << " \n State : " << LToString (Res.second ) << ' \n ' ;
532+ Warning<IDETypeStateAnalysisDomain<TypeStateDescriptionTy>>
533+ Warn (&I, Res.first , TSD->error ());
534+ // ERROR STATE DETECTED
535+ this ->Printer ->onResult (Warn);
549536 }
550- } else {
551- OS << " \n Inst: " << NToString (&I) << ' \n '
552- << " Fact: " << DToString (Res.first ) << ' \n '
553- << " State: " << LToString (Res.second ) << ' \n ' ;
554537 }
555538 }
556539 } else {
557540 for (auto Res : Results) {
558541 if (const auto *Alloca =
559542 llvm::dyn_cast<llvm::AllocaInst>(Res.first )) {
560543 if (Res.second == TSD->error ()) {
561- OS << " \n === ERROR STATE DETECTED ===\n Alloca: "
562- << DToString (Res.first ) << ' \n '
563- << " \n At IR Inst: " << NToString (&I) << ' \n ' ;
564- for (const auto *Pred : CFG.getPredsOf (&I)) {
565- OS << " \n Predecessor: " << NToString (Pred) << ' \n ' ;
566- auto PredResults = SR.resultsAt (Pred, true );
567- for (auto Res : PredResults) {
568- if (Res.first == Alloca) {
569- OS << " Pred State: " << LToString (Res.second ) << ' \n ' ;
570- }
571- }
572- }
573- OS << " ============================\n " ;
544+ Warning<IDETypeStateAnalysisDomain<TypeStateDescriptionTy>>
545+ Warn (&I, Res.first , TSD->error ());
546+ // ERROR STATE DETECTED
547+ this ->Printer ->onResult (Warn);
574548 }
575- } else {
576- OS << " \n Inst: " << NToString (&I) << ' \n '
577- << " Fact: " << DToString (Res.first ) << ' \n '
578- << " State: " << LToString (Res.second ) << ' \n ' ;
579549 }
580550 }
581551 }
582552 }
583553 }
584- OS << " \n --------------------------------------------\n " ;
585554 }
555+
556+ this ->Printer ->onFinalize (OS);
586557 }
587558
588559private:
0 commit comments