[clang] [NFC][analyzer] Silence gcc -Wempty-body when compiling unittest (PR #241759)

DonĂ¡t Nagy via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 12 01:51:52 PST 2026


https://github.com/NagyDonat created https://github.com/llvm/llvm-project/pull/241759

When I was building and running the static analyzer tests; gcc always emitted a `-Wempty-body` warning for this test file. Let's silence it to reduce noise during the build.

>From 564e67046c114b4d5b99b79f0306b3a8cc0229ca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Don=C3=A1t=20Nagy?= <donat.nagy at ericsson.com>
Date: Thu, 12 Nov 2026 10:48:32 +0100
Subject: [PATCH] [NFC][analyzer] Silence gcc -Wempty-body when compiling
 unittest

When I was building and running the static analyzer tests; gcc always
emitted a `-Wempty-body` warning for this test file. Let's silence it to
reduce noise during the build.
---
 clang/unittests/StaticAnalyzer/UnsignedStatDemo.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/clang/unittests/StaticAnalyzer/UnsignedStatDemo.cpp b/clang/unittests/StaticAnalyzer/UnsignedStatDemo.cpp
index 64f75c09ba942b..580b5f7ebfde97 100644
--- a/clang/unittests/StaticAnalyzer/UnsignedStatDemo.cpp
+++ b/clang/unittests/StaticAnalyzer/UnsignedStatDemo.cpp
@@ -39,12 +39,13 @@ class UnsignedStatTesterChecker : public Checker<check::BeginFunction> {
 
     // Conditionally set the statistic based on the function name (leaving it
     // undefined for all other functions)
-    if (Name == "func_one")
+    if (Name == "func_one") {
       DemoStat.set(1);
-    else if (Name == "func_two")
+    } else if (Name == "func_two") {
       DemoStat.set(2);
-    else
-      ; // For any other function (e.g., "func_none") don't set the statistic
+    } else {
+      // For any other function (e.g., "func_none") don't set the statistic
+    }
   }
 };
 



More information about the cfe-commits mailing list