[Lldb-commits] [lldb] [lldb] Fix MSVC warnings about missing return values (PR #215313)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Aug 10 08:51:31 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Nerixyz (Nerixyz)
<details>
<summary>Changes</summary>
MSVC warns with [C4715](https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4715) about missing returns in functions where a `switch` over and enum handles all names enumerators, because the enum could hold unnamed values. For example, given an `enum class Foo { Bar, Baz }` a function handles both `Bar` and `Baz` by returning a value, Clang and GCC won't issue warnings, but MSVC will.
This handles the cases in the two locations I found.
---
Full diff: https://github.com/llvm/llvm-project/pull/215313.diff
2 Files Affected:
- (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp (+3)
- (modified) lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp (+3)
``````````diff
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
index 4966eb1d75b20..79fe98a6e9d15 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
@@ -137,6 +137,9 @@ llvm::Expected<uint32_t> lldb_private::formatters::
case VectorLayout::Size:
return GetNumChildren(m_finish);
}
+
+ assert(false && "invalid vector layout");
+ return llvm::createStringError("invalid vector layout");
}
lldb::ValueObjectSP
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp b/lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp
index b1985cbb7d053..99e3ceec08fb2 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp
@@ -90,6 +90,9 @@ static llvm::json::Value toJSON(const StoppedReason &SR) {
case eStoppedReasonInstructionBreakpoint:
return "instruction breakpoint";
}
+
+ assert(false && "invalid StopReason");
+ return "";
}
llvm::json::Value toJSON(const StoppedEventBody &SEB) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/215313
More information about the lldb-commits
mailing list