From 506deb0cce3fe503f61ef1a1a08a40770ef4b978 Mon Sep 17 00:00:00 2001 From: foxtran <39676482+foxtran@users.noreply.github.com> Date: Fri, 21 Feb 2025 18:02:19 +0100 Subject: [PATCH] [lldb] Fix GCC's `-Wreturn-type` warnings (#127974) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch fixes `-Wreturn-type` warnings which happens if LLVM is built with GCC compiler (14.1 is used for detecting) Warnings: ``` llvm-project/lldb/source/ValueObject/DILLexer.cpp: In static member function ‘static llvm::StringRef lldb_private::dil::Token::GetTokenName(Kind)’: llvm-project/lldb/source/ValueObject/DILLexer.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type] 33 | } | ^ ``` and: ``` llvm-project/lldb/source/DataFormatters/TypeSummary.cpp: In member function ‘virtual std::string lldb_private::TypeSummaryImpl::GetSummaryKindName()’: llvm-project/lldb/source/DataFormatters/TypeSummary.cpp:62:1: warning: control reaches end of non-void function [-Wreturn-type] 62 | } | ^ ``` Technically, it is a bug in Clang (see #115345), however, UBSan with Clang should detect these places, therefore it would be nice to provide a return statement for all possible inputs (even invalid). --- lldb/source/DataFormatters/TypeSummary.cpp | 1 + lldb/source/ValueObject/DILLexer.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/lldb/source/DataFormatters/TypeSummary.cpp b/lldb/source/DataFormatters/TypeSummary.cpp index 2c863b364538..18bf81aedf2c 100644 --- a/lldb/source/DataFormatters/TypeSummary.cpp +++ b/lldb/source/DataFormatters/TypeSummary.cpp @@ -59,6 +59,7 @@ std::string TypeSummaryImpl::GetSummaryKindName() { case Kind::eBytecode: return "bytecode"; } + llvm_unreachable("Unknown type kind name"); } StringSummaryFormat::StringSummaryFormat(const TypeSummaryImpl::Flags &flags, diff --git a/lldb/source/ValueObject/DILLexer.cpp b/lldb/source/ValueObject/DILLexer.cpp index c7acfec347af..1f013288c839 100644 --- a/lldb/source/ValueObject/DILLexer.cpp +++ b/lldb/source/ValueObject/DILLexer.cpp @@ -30,6 +30,7 @@ llvm::StringRef Token::GetTokenName(Kind kind) { case Kind::r_paren: return "r_paren"; } + llvm_unreachable("Unknown token name"); } static bool IsLetter(char c) {