-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb] Fix GCC's -Wreturn-type
warnings
#127974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-lldb Author: None (foxtran) ChangesThis patch fixes Warnings:
and:
Technically, it is a bug in GCC (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). Full diff: https://github.com/llvm/llvm-project/pull/127974.diff 2 Files Affected:
diff --git a/lldb/source/DataFormatters/TypeSummary.cpp b/lldb/source/DataFormatters/TypeSummary.cpp
index 2c863b364538f..1b73efa398d43 100644
--- a/lldb/source/DataFormatters/TypeSummary.cpp
+++ b/lldb/source/DataFormatters/TypeSummary.cpp
@@ -58,6 +58,8 @@ std::string TypeSummaryImpl::GetSummaryKindName() {
return "c++";
case Kind::eBytecode:
return "bytecode";
+ case default:
+ return "unknown";
}
}
diff --git a/lldb/source/ValueObject/DILLexer.cpp b/lldb/source/ValueObject/DILLexer.cpp
index c7acfec347af4..a637fc1c978c7 100644
--- a/lldb/source/ValueObject/DILLexer.cpp
+++ b/lldb/source/ValueObject/DILLexer.cpp
@@ -29,6 +29,8 @@ llvm::StringRef Token::GetTokenName(Kind kind) {
return "l_paren";
case Kind::r_paren:
return "r_paren";
+ case default:
+ return "unknown";
}
}
|
5d5aea8
to
c51a546
Compare
c51a546
to
d36ed84
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default clause prevents the "uncovered enumerator" from firing is a new value is added to the enum (and it's actually against the coding standards). The recommended solution is to place llvm_unreachable after the switch like so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
@JDevlieghere, it is still not merged. Are there any extra checks? |
Nope, I just wasn't sure if you had commit access. I'll go ahead and merge it for you. |
This patch fixes
-Wreturn-type
warnings which happens if LLVM is built with GCC compiler (14.1 is used for detecting)Warnings:
and:
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).