[clang] [Clang] Fix false-positive fallthrough warning (PR #234848)

Chen Miao via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 5 22:55:10 PST 2026


================
@@ -253,6 +253,82 @@ int fallthrough_covered_enums(Enum e) {
   return n;
 }
 
+// Attributes on consecutive switch labels should not introduce false fallthrough.
+int fallthrough_attributed_labels(int n) {
+  switch (n) {
+  [[unlikely]] case 0:
+  [[unlikely]] case 1:
+  [[likely]] case 2:
+  case 3:
+  [[unlikely]] case 4:
+  [[unlikely]] default:
+    return -1;
+  }
+  switch (n) {
----------------
ChenMiaoi wrote:

Can you split this switch to a single function like others?

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


More information about the cfe-commits mailing list