Lines Matching +full:class +full:- +full:dg
1 //===--- AnalysisConsumer.cpp - ASTConsumer for running Analyses ----------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
64 //===----------------------------------------------------------------------===//
66 //===----------------------------------------------------------------------===//
70 class AnalysisConsumer : public AnalysisASTConsumer,
96 /// Note, we pre-compute the local declarations at parse time as an
136 "syntaxchecks", "Syntax-based analysis time", *AnalyzerTimers); in AnalysisConsumer()
140 "bugreporter", "Path-sensitive report post-processing time", in AnalysisConsumer()
197 SourceManager &SM = Mgr->getASTContext().getSourceManager(); in DisplayFunction()
198 PresumedLoc Loc = SM.getPresumedLoc(D->getLocation()); in DisplayFunction()
234 /// (Doing this pre-processing avoids deserialization of data from PCH.)
251 /// \param Mode - determines if we are requesting syntax only or path
253 /// \param VisitedCallees - The output parameter, which is populated with the
272 SyntaxCheckTimer->startTimer(); in VisitDecl()
273 checkerMgr->runCheckersOnASTDecl(D, *Mgr, *RecVisitorBR); in VisitDecl()
275 SyntaxCheckTimer->stopTimer(); in VisitDecl()
284 if (VD->hasExternalStorage() || VD->isStaticDataMember()) { in VisitVarDecl()
292 if (VD->getAnyInitializer()) in VisitVarDecl()
310 IdentifierInfo *II = FD->getIdentifier(); in VisitFunctionDecl()
311 if (II && II->getName().starts_with("__inline")) in VisitFunctionDecl()
316 if (FD->isThisDeclarationADefinition() && in VisitFunctionDecl()
317 !FD->isDependentContext()) { in VisitFunctionDecl()
318 assert(RecVisitorMode == AM_Syntax || Mgr->shouldInlineCall() == false); in VisitFunctionDecl()
325 if (MD->isThisDeclarationADefinition()) { in VisitObjCMethodDecl()
326 assert(RecVisitorMode == AM_Syntax || Mgr->shouldInlineCall() == false); in VisitObjCMethodDecl()
333 if (BD->hasBody()) { in VisitBlockDecl()
334 assert(RecVisitorMode == AM_Syntax || Mgr->shouldInlineCall() == false); in VisitBlockDecl()
337 if (!BD->isDependentContext()) { in VisitBlockDecl()
353 void storeTopLevelDecls(DeclGroupRef DG);
365 //===----------------------------------------------------------------------===//
367 //===----------------------------------------------------------------------===//
368 bool AnalysisConsumer::HandleTopLevelDecl(DeclGroupRef DG) { in HandleTopLevelDecl() argument
369 storeTopLevelDecls(DG); in HandleTopLevelDecl()
373 void AnalysisConsumer::HandleTopLevelDeclInObjCContainer(DeclGroupRef DG) { in HandleTopLevelDeclInObjCContainer() argument
374 storeTopLevelDecls(DG); in HandleTopLevelDeclInObjCContainer()
377 void AnalysisConsumer::storeTopLevelDecls(DeclGroupRef DG) { in storeTopLevelDecls() argument
378 for (auto &I : DG) { in storeTopLevelDecls()
395 // Skip analysis of inheriting constructors as top-level functions. These in shouldSkipFunction()
399 if (CD->isInheritingConstructor()) in shouldSkipFunction()
402 // We want to re-analyse the functions as top level in the following cases: in shouldSkipFunction()
403 // - The 'init' methods should be reanalyzed because in shouldSkipFunction()
407 // - We want to reanalyze all ObjC methods as top level to report Retain in shouldSkipFunction()
415 if (MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator()) in shouldSkipFunction()
431 if (ObjCM->getMethodFamily() != OMF_init) in getInliningModeForFunction()
460 Decl *D = N->getDecl(); in HandleDeclsCallGraph()
478 FD->hasBody(FD); in HandleDeclsCallGraph()
487 (Mgr->options.InliningMode == All ? nullptr : &VisitedCallees)); in HandleDeclsCallGraph()
494 : Callee->getCanonicalDecl()); in HandleDeclsCallGraph()
508 llvm::errs() << "Every top-level function was skipped.\n"; in reportAnalyzerFunctionMisuse()
511 llvm::errs() << "Pass the -analyzer-display-progress for tracking which " in reportAnalyzerFunctionMisuse()
520 "list: -analyze-function=\"foobar(int, _Bool)\"\n"; in reportAnalyzerFunctionMisuse()
524 "-analyze-function=foobar\n"; in reportAnalyzerFunctionMisuse()
533 SyntaxCheckTimer->startTimer(); in runAnalysisOnTranslationUnit()
534 checkerMgr->runCheckersOnASTDecl(TU, *Mgr, BR); in runAnalysisOnTranslationUnit()
536 SyntaxCheckTimer->stopTimer(); in runAnalysisOnTranslationUnit()
538 // Run the AST-only checks using the order in which functions are defined. in runAnalysisOnTranslationUnit()
542 if (!Mgr->shouldInlineCall()) in runAnalysisOnTranslationUnit()
557 if (Mgr->shouldInlineCall()) in runAnalysisOnTranslationUnit()
561 checkerMgr->runCheckersOnEndOfTranslationUnit(TU, *Mgr, BR); in runAnalysisOnTranslationUnit()
588 // side-effects in PathDiagnosticConsumer's destructor. This is required when in HandleTranslationUnit()
589 // used with option -disable-free. in HandleTranslationUnit()
595 reportAnalyzerProgress("Skipping bison-generated file\n"); in HandleTranslationUnit()
601 reportAnalyzerProgress("Skipping flex-generated file\n"); in HandleTranslationUnit()
631 // Unless -analyze-all is specified, treat decls differently depending on in getModeForDecl()
633 // - Main source file: run both path-sensitive and non-path-sensitive checks. in getModeForDecl()
634 // - Header files: run non-path-sensitive checks only. in getModeForDecl()
635 // - System headers: don't run any checks. in getModeForDecl()
639 const SourceManager &SM = Ctx->getSourceManager(); in getModeForDecl()
641 const SourceLocation Loc = [&SM](Decl *D) -> SourceLocation { in getModeForDecl()
642 const Stmt *Body = D->getBody(); in getModeForDecl()
643 SourceLocation SL = Body ? Body->getBeginLoc() : D->getLocation(); in getModeForDecl()
651 // Disable path sensitive analysis in user-headers. in getModeForDecl()
652 if (!Mgr->isInCodeFile(Loc)) in getModeForDecl()
661 if (!D->hasBody()) in HandleCode()
668 Mgr->ClearContexts(); in HandleCode()
670 if (Mgr->getAnalysisDeclContext(D)->isBodyAutosynthesized()) in HandleCode()
673 CFG *DeclCFG = Mgr->getCFG(D); in HandleCode()
675 MaxCFGSize.updateMax(DeclCFG->size()); in HandleCode()
684 CheckerStartTime = SyntaxCheckTimer->getTotalTime(); in HandleCode()
685 SyntaxCheckTimer->startTimer(); in HandleCode()
687 checkerMgr->runCheckersOnASTBody(D, *Mgr, BR); in HandleCode()
689 SyntaxCheckTimer->stopTimer(); in HandleCode()
690 llvm::TimeRecord CheckerEndTime = SyntaxCheckTimer->getTotalTime(); in HandleCode()
691 CheckerEndTime -= CheckerStartTime; in HandleCode()
698 if ((Mode & AM_Path) && checkerMgr->hasPathSensitiveCheckers()) { in HandleCode()
705 //===----------------------------------------------------------------------===//
706 // Path-sensitive checking.
707 //===----------------------------------------------------------------------===//
713 // FIXME: Inter-procedural analysis will need to handle invalid CFGs. in RunPathSensitiveChecks()
714 if (!Mgr->getCFG(D)) in RunPathSensitiveChecks()
718 if (!Mgr->getAnalysisDeclContext(D)->getAnalysis<RelaxedLiveVariables>()) in RunPathSensitiveChecks()
726 ExprEngineStartTime = ExprEngineTimer->getTotalTime(); in RunPathSensitiveChecks()
727 ExprEngineTimer->startTimer(); in RunPathSensitiveChecks()
729 Eng.ExecuteWorkList(Mgr->getAnalysisDeclContextManager().getStackFrame(D), in RunPathSensitiveChecks()
730 Mgr->options.MaxNodesPerTopLevelFunction); in RunPathSensitiveChecks()
732 ExprEngineTimer->stopTimer(); in RunPathSensitiveChecks()
733 llvm::TimeRecord ExprEngineEndTime = ExprEngineTimer->getTotalTime(); in RunPathSensitiveChecks()
734 ExprEngineEndTime -= ExprEngineStartTime; in RunPathSensitiveChecks()
738 if (!Mgr->options.DumpExplodedGraphTo.empty()) in RunPathSensitiveChecks()
739 Eng.DumpGraph(Mgr->options.TrimGraph, Mgr->options.DumpExplodedGraphTo); in RunPathSensitiveChecks()
742 if (Mgr->options.visualizeExplodedGraphWithGraphViz) in RunPathSensitiveChecks()
743 Eng.ViewGraph(Mgr->options.TrimGraph); in RunPathSensitiveChecks()
747 BugReporterTimer->startTimer(); in RunPathSensitiveChecks()
750 BugReporterTimer->stopTimer(); in RunPathSensitiveChecks()
753 //===----------------------------------------------------------------------===//
755 //===----------------------------------------------------------------------===//
759 // Disable the effects of '-Werror' when using the AnalysisConsumer. in CreateAnalysisConsumer()
763 bool hasModelPath = analyzerOpts.Config.count("model-path") > 0; in CreateAnalysisConsumer()