Author: foxtran
Date: 2025-02-21T11:02:19-06:00
New Revision: 506deb0cce3fe503f61ef1a1a08a40770ef4b978

URL: 
https://github.com/llvm/llvm-project/commit/506deb0cce3fe503f61ef1a1a08a40770ef4b978
DIFF: 
https://github.com/llvm/llvm-project/commit/506deb0cce3fe503f61ef1a1a08a40770ef4b978.diff

LOG: [lldb] Fix GCC's `-Wreturn-type` warnings (#127974)

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).

Added: 
    

Modified: 
    lldb/source/DataFormatters/TypeSummary.cpp
    lldb/source/ValueObject/DILLexer.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/DataFormatters/TypeSummary.cpp 
b/lldb/source/DataFormatters/TypeSummary.cpp
index 2c863b364538f..18bf81aedf2cb 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 c7acfec347af4..1f013288c839b 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) {


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to