[clang] [NFCI][analyzer] Add BranchCondition callback to 'switch' (PR #182058)

via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 18 08:53:25 PST 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,c -- clang/test/Analysis/uninitialized-branch.c clang/lib/StaticAnalyzer/Core/ExprEngine.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index be7d36651..9e8b7e928 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -3114,8 +3114,8 @@ void ExprEngine::processSwitch(NodeBuilderContext &BC, const SwitchStmt *Switch,
   SwitchNodeBuilder Builder(Dst, BC);
   ExplodedNodeSet CheckersOutSet;
 
-  getCheckerManager().runCheckersForBranchCondition(Condition->IgnoreParens(), CheckersOutSet,
-                                                    Pred, *this);
+  getCheckerManager().runCheckersForBranchCondition(
+      Condition->IgnoreParens(), CheckersOutSet, Pred, *this);
 
   for (ExplodedNode *Node : CheckersOutSet) {
     ProgramStateRef State = Node->getState();
@@ -3137,7 +3137,8 @@ void ExprEngine::processSwitch(NodeBuilderContext &BC, const SwitchStmt *Switch,
 
       // Evaluate the LHS of the case value.
       llvm::APSInt V1 = Case->getLHS()->EvaluateKnownConstInt(getContext());
-      assert(V1.getBitWidth() == getContext().getIntWidth(Condition->getType()));
+      assert(V1.getBitWidth() ==
+             getContext().getIntWidth(Condition->getType()));
 
       // Get the RHS of the case, if it exists.
       llvm::APSInt V2;

``````````

</details>


https://github.com/llvm/llvm-project/pull/182058


More information about the cfe-commits mailing list