Lines Matching +full:level +full:- +full:sensitive

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