https://github.com/marco-milanese-sonarsource updated https://github.com/llvm/llvm-project/pull/220588
>From 765cb016953ba30e1bdf6bd8d8c3775dd353915b Mon Sep 17 00:00:00 2001 From: Marco Milanese <[email protected]> Date: Wed, 2 Sep 2026 15:06:53 +0200 Subject: [PATCH 1/5] [analyzer][NFC] Fix typo in `exploredAllPaths` variable & predicate --- .../clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h | 6 +++--- .../clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h | 2 +- .../lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp | 2 +- clang/lib/StaticAnalyzer/Core/CoreEngine.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h index 67bd1504d5ffb..05091c8ad64da 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h @@ -84,7 +84,7 @@ class CoreEngine { /// Whether the single-TU phase ran out of budget with work left over. /// The CTU phase replaces \c WList, so this has to be remembered separately. - bool exploredAllSTUPaths = false; + bool notExploredAllSTUPaths = false; /// The information about functions shared by the whole translation unit. /// (This data is owned by AnalysisConsumer.) @@ -150,8 +150,8 @@ class CoreEngine { // Functions for external checking of whether we have unfinished work. bool wasBlockAborted() const { return !blocksAborted.empty(); } bool wasBlocksExhausted() const { return !blocksExhausted.empty(); } - bool hasExploredAllPaths() const { - return wasBlocksExhausted() || WList->hasWork() || exploredAllSTUPaths || + bool hasNotExploredAllPaths() const { + return wasBlocksExhausted() || WList->hasWork() || notExploredAllSTUPaths || wasBlockAborted(); } diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h index 195d63b0e0936..2e891cae75f1c 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h @@ -467,7 +467,7 @@ class ExprEngine { // Functions for external checking of whether we have unfinished work. bool wasBlocksExhausted() const { return Engine.wasBlocksExhausted(); } bool hasEmptyWorkList() const { return !Engine.getWorkList()->hasWork(); } - bool hasExploredAllPaths() const { return Engine.hasExploredAllPaths(); } + bool hasNotExploredAllPaths() const { return Engine.hasNotExploredAllPaths(); } const CoreEngine &getCoreEngine() const { return Engine; } diff --git a/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp index 57b079e40e6c4..3d2a2aa6d8b1c 100644 --- a/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp @@ -51,7 +51,7 @@ void UnreachableCodeChecker::checkEndAnalysis(ExplodedGraph &G, ExprEngine &Eng) const { CFGBlocksSet reachable, visited; - if (Eng.hasExploredAllPaths()) + if (Eng.hasNotExploredAllPaths()) return; const Decl *D = nullptr; diff --git a/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp b/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp index 593346b2354a1..f0de0e141cc59 100644 --- a/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp @@ -161,7 +161,7 @@ bool CoreEngine::ExecuteWorkList(const StackFrame *SF, unsigned MaxSteps, return MaxSteps - Steps; }; const unsigned STUSteps = ProcessWList(MaxSteps); - exploredAllSTUPaths = WList->hasWork(); + notExploredAllSTUPaths = WList->hasWork(); if (CTUWList) { NumSTUSteps += STUSteps; >From b917316e2844c8149a9d55e90368455dc8fc14b3 Mon Sep 17 00:00:00 2001 From: Marco Milanese <[email protected]> Date: Wed, 2 Sep 2026 18:00:33 +0200 Subject: [PATCH 2/5] format --- .../clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h index 2e891cae75f1c..f3a2abe86bc64 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h @@ -467,7 +467,9 @@ class ExprEngine { // Functions for external checking of whether we have unfinished work. bool wasBlocksExhausted() const { return Engine.wasBlocksExhausted(); } bool hasEmptyWorkList() const { return !Engine.getWorkList()->hasWork(); } - bool hasNotExploredAllPaths() const { return Engine.hasNotExploredAllPaths(); } + bool hasNotExploredAllPaths() const { + return Engine.hasNotExploredAllPaths(); + } const CoreEngine &getCoreEngine() const { return Engine; } >From ea50fa45cf9093f97a79371c39ffd114f4fe9311 Mon Sep 17 00:00:00 2001 From: Marco Milanese <[email protected]> Date: Thu, 3 Sep 2026 08:51:45 +0200 Subject: [PATCH 3/5] Revert "format" This reverts commit b917316e2844c8149a9d55e90368455dc8fc14b3. --- .../clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h index f3a2abe86bc64..2e891cae75f1c 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h @@ -467,9 +467,7 @@ class ExprEngine { // Functions for external checking of whether we have unfinished work. bool wasBlocksExhausted() const { return Engine.wasBlocksExhausted(); } bool hasEmptyWorkList() const { return !Engine.getWorkList()->hasWork(); } - bool hasNotExploredAllPaths() const { - return Engine.hasNotExploredAllPaths(); - } + bool hasNotExploredAllPaths() const { return Engine.hasNotExploredAllPaths(); } const CoreEngine &getCoreEngine() const { return Engine; } >From 6a4707597cde0a3c5a6ed1c17ac50f79ccf4e1de Mon Sep 17 00:00:00 2001 From: Marco Milanese <[email protected]> Date: Thu, 3 Sep 2026 08:51:52 +0200 Subject: [PATCH 4/5] Revert "[analyzer][NFC] Fix typo in `exploredAllPaths` variable & predicate" This reverts commit 765cb016953ba30e1bdf6bd8d8c3775dd353915b. --- .../clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h | 6 +++--- .../clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h | 2 +- .../lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp | 2 +- clang/lib/StaticAnalyzer/Core/CoreEngine.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h index 05091c8ad64da..67bd1504d5ffb 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h @@ -84,7 +84,7 @@ class CoreEngine { /// Whether the single-TU phase ran out of budget with work left over. /// The CTU phase replaces \c WList, so this has to be remembered separately. - bool notExploredAllSTUPaths = false; + bool exploredAllSTUPaths = false; /// The information about functions shared by the whole translation unit. /// (This data is owned by AnalysisConsumer.) @@ -150,8 +150,8 @@ class CoreEngine { // Functions for external checking of whether we have unfinished work. bool wasBlockAborted() const { return !blocksAborted.empty(); } bool wasBlocksExhausted() const { return !blocksExhausted.empty(); } - bool hasNotExploredAllPaths() const { - return wasBlocksExhausted() || WList->hasWork() || notExploredAllSTUPaths || + bool hasExploredAllPaths() const { + return wasBlocksExhausted() || WList->hasWork() || exploredAllSTUPaths || wasBlockAborted(); } diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h index 2e891cae75f1c..195d63b0e0936 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h @@ -467,7 +467,7 @@ class ExprEngine { // Functions for external checking of whether we have unfinished work. bool wasBlocksExhausted() const { return Engine.wasBlocksExhausted(); } bool hasEmptyWorkList() const { return !Engine.getWorkList()->hasWork(); } - bool hasNotExploredAllPaths() const { return Engine.hasNotExploredAllPaths(); } + bool hasExploredAllPaths() const { return Engine.hasExploredAllPaths(); } const CoreEngine &getCoreEngine() const { return Engine; } diff --git a/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp index 3d2a2aa6d8b1c..57b079e40e6c4 100644 --- a/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp @@ -51,7 +51,7 @@ void UnreachableCodeChecker::checkEndAnalysis(ExplodedGraph &G, ExprEngine &Eng) const { CFGBlocksSet reachable, visited; - if (Eng.hasNotExploredAllPaths()) + if (Eng.hasExploredAllPaths()) return; const Decl *D = nullptr; diff --git a/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp b/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp index f0de0e141cc59..593346b2354a1 100644 --- a/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp @@ -161,7 +161,7 @@ bool CoreEngine::ExecuteWorkList(const StackFrame *SF, unsigned MaxSteps, return MaxSteps - Steps; }; const unsigned STUSteps = ProcessWList(MaxSteps); - notExploredAllSTUPaths = WList->hasWork(); + exploredAllSTUPaths = WList->hasWork(); if (CTUWList) { NumSTUSteps += STUSteps; >From 265da4bf869cf3c4ac477b69a765f7447a9060e0 Mon Sep 17 00:00:00 2001 From: Marco Milanese <[email protected]> Date: Thu, 3 Sep 2026 09:27:25 +0200 Subject: [PATCH 5/5] flip condition --- .../clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h | 9 +++++---- .../StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp | 2 +- clang/lib/StaticAnalyzer/Core/CoreEngine.cpp | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h index 67bd1504d5ffb..04906ef6c7189 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h @@ -82,9 +82,10 @@ class CoreEngine { /// usually because it could not reason about something. BlocksAborted blocksAborted; - /// Whether the single-TU phase ran out of budget with work left over. + /// Whether the single-TU phase completed the exploration of all paths + /// within its budget limit. /// The CTU phase replaces \c WList, so this has to be remembered separately. - bool exploredAllSTUPaths = false; + bool ExploredAllSTUPaths = false; /// The information about functions shared by the whole translation unit. /// (This data is owned by AnalysisConsumer.) @@ -151,8 +152,8 @@ class CoreEngine { bool wasBlockAborted() const { return !blocksAborted.empty(); } bool wasBlocksExhausted() const { return !blocksExhausted.empty(); } bool hasExploredAllPaths() const { - return wasBlocksExhausted() || WList->hasWork() || exploredAllSTUPaths || - wasBlockAborted(); + return !wasBlocksExhausted() && !WList->hasWork() && ExploredAllSTUPaths && + !wasBlockAborted(); } /// Inform the CoreEngine that a basic block was aborted because diff --git a/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp index 57b079e40e6c4..84b744fac751e 100644 --- a/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp @@ -51,7 +51,7 @@ void UnreachableCodeChecker::checkEndAnalysis(ExplodedGraph &G, ExprEngine &Eng) const { CFGBlocksSet reachable, visited; - if (Eng.hasExploredAllPaths()) + if (!Eng.hasExploredAllPaths()) return; const Decl *D = nullptr; diff --git a/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp b/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp index 593346b2354a1..04b700726fbc6 100644 --- a/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp @@ -161,7 +161,7 @@ bool CoreEngine::ExecuteWorkList(const StackFrame *SF, unsigned MaxSteps, return MaxSteps - Steps; }; const unsigned STUSteps = ProcessWList(MaxSteps); - exploredAllSTUPaths = WList->hasWork(); + ExploredAllSTUPaths = !WList->hasWork(); if (CTUWList) { NumSTUSteps += STUSteps; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
