[Lldb-commits] [lldb] [lldb] Add unreachable after fully covered switches, avoid GCC warnings. NFC. (PR #159327)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Sep 17 04:44:37 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Martin Storsjö (mstorsjo)
<details>
<summary>Changes</summary>
This avoids the following kind of warning with GCC:
warning: control reaches end of non-void function [-Wreturn-type]
---
Full diff: https://github.com/llvm/llvm-project/pull/159327.diff
4 Files Affected:
- (modified) lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp (+1)
- (modified) lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp (+1)
- (modified) lldb/source/Plugins/Process/wasm/ProcessWasm.cpp (+1)
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+2)
``````````diff
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 1f7b8d48d0fc8..4e8a430af8c6c 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -2199,6 +2199,7 @@ bool CPlusPlusLanguage::GetFunctionDisplayName(
case FunctionNameRepresentation::eName:
return false;
}
+ llvm_unreachable("Fully covered switch above");
}
bool CPlusPlusLanguage::HandleFrameFormatVariable(
diff --git a/lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp b/lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp
index 3b0618fa10374..1204faf4fa61e 100644
--- a/lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp
+++ b/lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp
@@ -60,6 +60,7 @@ static bool BehavesLikeZerothFrame(HistoryPCType pc_type, uint32_t frame_idx) {
case HistoryPCType::Calls:
return true;
}
+ llvm_unreachable("Fully covered switch above");
}
bool HistoryUnwind::DoGetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa,
diff --git a/lldb/source/Plugins/Process/wasm/ProcessWasm.cpp b/lldb/source/Plugins/Process/wasm/ProcessWasm.cpp
index 580e8c1d9cfa4..62bcf442d097a 100644
--- a/lldb/source/Plugins/Process/wasm/ProcessWasm.cpp
+++ b/lldb/source/Plugins/Process/wasm/ProcessWasm.cpp
@@ -98,6 +98,7 @@ size_t ProcessWasm::ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
"Wasm read failed for invalid address 0x%" PRIx64, vm_addr);
return 0;
}
+ llvm_unreachable("Fully covered switch above");
}
llvm::Expected<std::vector<lldb::addr_t>>
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 5801fa97bf753..881268bc4ca03 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2502,6 +2502,7 @@ static llvm::StringRef ClangToItaniumCtorKind(clang::CXXCtorType kind) {
case clang::CXXCtorType::Ctor_Comdat:
llvm_unreachable("Unexpected constructor kind.");
}
+ llvm_unreachable("Fully covered switch above");
}
static llvm::StringRef ClangToItaniumDtorKind(clang::CXXDtorType kind) {
@@ -2517,6 +2518,7 @@ static llvm::StringRef ClangToItaniumDtorKind(clang::CXXDtorType kind) {
case clang::CXXDtorType::Dtor_Comdat:
llvm_unreachable("Unexpected destructor kind.");
}
+ llvm_unreachable("Fully covered switch above");
}
static llvm::StringRef
``````````
</details>
https://github.com/llvm/llvm-project/pull/159327
More information about the lldb-commits
mailing list