Author: Valeriy Savchenko Date: 2021-06-11T12:49:03+03:00 New Revision: f853d2601abd4f6ab789ca1513ae8b59ba5d38b7
URL: https://github.com/llvm/llvm-project/commit/f853d2601abd4f6ab789ca1513ae8b59ba5d38b7 DIFF: https://github.com/llvm/llvm-project/commit/f853d2601abd4f6ab789ca1513ae8b59ba5d38b7.diff LOG: [analyzer] Turn ReturnVisitor into a tracking visitor Whenever Tracker spawns a visitor that needs to call tracker back, we have to use TrackingBugReporterVisitor in order to maintain all the hooks that the checker might've used. Differential Revision: https://reviews.llvm.org/D103628 Added: Modified: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Removed: ################################################################################ diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp index af553a2b5903..651c80276110 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -906,7 +906,7 @@ namespace { /// /// This visitor is intended to be used when another visitor discovers that an /// interesting value comes from an inlined function call. -class ReturnVisitor : public BugReporterVisitor { +class ReturnVisitor : public TrackingBugReporterVisitor { const StackFrameContext *CalleeSFC; enum { Initial, @@ -920,10 +920,11 @@ class ReturnVisitor : public BugReporterVisitor { bugreporter::TrackingKind TKind; public: - ReturnVisitor(const StackFrameContext *Frame, bool Suppressed, - AnalyzerOptions &Options, bugreporter::TrackingKind TKind) - : CalleeSFC(Frame), EnableNullFPSuppression(Suppressed), - Options(Options), TKind(TKind) {} + ReturnVisitor(TrackerRef ParentTracker, const StackFrameContext *Frame, + bool Suppressed, AnalyzerOptions &Options, + bugreporter::TrackingKind TKind) + : TrackingBugReporterVisitor(ParentTracker), CalleeSFC(Frame), + EnableNullFPSuppression(Suppressed), Options(Options), TKind(TKind) {} static void *getTag() { static int Tag = 0; @@ -943,7 +944,8 @@ class ReturnVisitor : public BugReporterVisitor { /// node, looking for when the given statement was processed. If it turns out /// the statement is a call that was inlined, we add the visitor to the /// bug report, so it can print a note later. - static void addVisitorIfNecessary(const ExplodedNode *Node, const Stmt *S, + static void addVisitorIfNecessary(TrackerRef ParentTracker, + const ExplodedNode *Node, const Stmt *S, PathSensitiveBugReport &BR, bool InEnableNullFPSuppression, bugreporter::TrackingKind TKind) { @@ -1016,8 +1018,8 @@ class ReturnVisitor : public BugReporterVisitor { if (Optional<Loc> RetLoc = RetVal.getAs<Loc>()) EnableNullFPSuppression = State->isNull(*RetLoc).isConstrainedTrue(); - BR.addVisitor<ReturnVisitor>(CalleeContext, EnableNullFPSuppression, - Options, TKind); + BR.addVisitor<ReturnVisitor>(ParentTracker, CalleeContext, + EnableNullFPSuppression, Options, TKind); } PathDiagnosticPieceRef visitNodeInitial(const ExplodedNode *N, @@ -1066,8 +1068,7 @@ class ReturnVisitor : public BugReporterVisitor { RetE = RetE->IgnoreParenCasts(); // Let's track the return value. - bugreporter::trackExpressionValue( - N, RetE, BR, TKind, EnableNullFPSuppression); + getParentTracker().track(RetE, N, {TKind, EnableNullFPSuppression}); // Build an appropriate message based on the return value. SmallString<64> Msg; @@ -1183,7 +1184,9 @@ class ReturnVisitor : public BugReporterVisitor { if (!State->isNull(*ArgV).isConstrainedTrue()) continue; - if (trackExpressionValue(N, ArgE, BR, TKind, EnableNullFPSuppression)) + if (getParentTracker() + .track(ArgE, N, {TKind, EnableNullFPSuppression}) + .FoundSomethingToTrack) ShouldInvalidate = false; // If we /can't/ track the null pointer, we should err on the side of @@ -2197,8 +2200,9 @@ class DefaultExpressionHandler final : public ExpressionHandler { // track the constraints on its contents. SVal V = LVState->getSValAsScalarOrLoc(Inner, LVNode->getLocationContext()); - ReturnVisitor::addVisitorIfNecessary( - LVNode, Inner, Report, Opts.EnableNullFPSuppression, Opts.Kind); + ReturnVisitor::addVisitorIfNecessary(&getParentTracker(), LVNode, Inner, + Report, Opts.EnableNullFPSuppression, + Opts.Kind); // Is it a symbolic value? if (auto L = V.getAs<loc::MemRegionVal>()) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits