https://github.com/mstorsjo created 
https://github.com/llvm/llvm-project/pull/159330

This avoids the following warnings:

    ../../clang/lib/AST/ExprConstant.cpp: In member function ‘bool 
{anonymous}::IntExprEvaluator::VisitBuiltinCallExpr(const clang::CallExpr*, 
unsigned int)’:
    ../../clang/lib/AST/ExprConstant.cpp:14104:3: warning: this statement may 
fall through [-Wimplicit-fallthrough=]
    14104 |   }
          |   ^
    ../../clang/lib/AST/ExprConstant.cpp:14105:3: note: here
    14105 |   case Builtin::BIstrlen:
          |   ^~~~
    ../../clang/lib/Driver/ToolChains/CommonArgs.cpp: In function ‘std::string 
clang::driver::tools::complexRangeKindToStr(clang::LangOptionsBase::ComplexRangeKind
 ’:
    ../../clang/lib/Driver/ToolChains/CommonArgs.cpp:3523:1: warning: control 
reaches end of non-void function [-Wreturn-type]
     3523 | }
          | ^

From d5a8d02e0ee4b75182cc2a15eef44aa0eca6bf1a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <[email protected]>
Date: Wed, 17 Sep 2025 14:26:57 +0300
Subject: [PATCH] [clang] Add unreachable after fully covered switches, avoid
 GCC warnings. NFC.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This avoids the following warnings:

    ../../clang/lib/AST/ExprConstant.cpp: In member function ‘bool 
{anonymous}::IntExprEvaluator::VisitBuiltinCallExpr(const clang::CallExpr*, 
unsigned int)’:
    ../../clang/lib/AST/ExprConstant.cpp:14104:3: warning: this statement may 
fall through [-Wimplicit-fallthrough=]
    14104 |   }
          |   ^
    ../../clang/lib/AST/ExprConstant.cpp:14105:3: note: here
    14105 |   case Builtin::BIstrlen:
          |   ^~~~
    ../../clang/lib/Driver/ToolChains/CommonArgs.cpp: In function ‘std::string 
clang::driver::tools::complexRangeKindToStr(clang::LangOptionsBase::ComplexRangeKind
 ’:
    ../../clang/lib/Driver/ToolChains/CommonArgs.cpp:3523:1: warning: control 
reaches end of non-void function [-Wreturn-type]
     3523 | }
          | ^
---
 clang/lib/AST/ExprConstant.cpp             | 1 +
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 1 +
 2 files changed, 2 insertions(+)

diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 12e4e25bd29c4..15c4a323b7d6a 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -14101,6 +14101,7 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const 
CallExpr *E,
       return Success(Result, E);
     }
     }
+    llvm_unreachable("Fully covered switch above");
   }
   case Builtin::BIstrlen:
   case Builtin::BIwcslen:
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index b50549219e4e8..08cd98fd04df0 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -3520,6 +3520,7 @@ std::string 
tools::complexRangeKindToStr(LangOptions::ComplexRangeKind Range) {
     return "none";
     break;
   }
+  llvm_unreachable("Fully covered switch above");
 }
 
 std::string

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to