Skip to content

Commit 4ff113f

Browse files
authored
[lldb] Add unreachable after fully covered switches, avoid GCC warnings. NFC. (#159327)
This avoids the following kind of warning with GCC: warning: control reaches end of non-void function [-Wreturn-type]
1 parent 2caf4c1 commit 4ff113f

File tree

4 files changed

+5
-0
lines changed

4 files changed

+5
-0
lines changed

lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2199,6 +2199,7 @@ bool CPlusPlusLanguage::GetFunctionDisplayName(
21992199
case FunctionNameRepresentation::eName:
22002200
return false;
22012201
}
2202+
llvm_unreachable("Fully covered switch above");
22022203
}
22032204

22042205
bool CPlusPlusLanguage::HandleFrameFormatVariable(

lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ static bool BehavesLikeZerothFrame(HistoryPCType pc_type, uint32_t frame_idx) {
6060
case HistoryPCType::Calls:
6161
return true;
6262
}
63+
llvm_unreachable("Fully covered switch above");
6364
}
6465

6566
bool HistoryUnwind::DoGetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa,

lldb/source/Plugins/Process/wasm/ProcessWasm.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ size_t ProcessWasm::ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
9898
"Wasm read failed for invalid address 0x%" PRIx64, vm_addr);
9999
return 0;
100100
}
101+
llvm_unreachable("Fully covered switch above");
101102
}
102103

103104
llvm::Expected<std::vector<lldb::addr_t>>

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2502,6 +2502,7 @@ static llvm::StringRef ClangToItaniumCtorKind(clang::CXXCtorType kind) {
25022502
case clang::CXXCtorType::Ctor_Comdat:
25032503
llvm_unreachable("Unexpected constructor kind.");
25042504
}
2505+
llvm_unreachable("Fully covered switch above");
25052506
}
25062507

25072508
static llvm::StringRef ClangToItaniumDtorKind(clang::CXXDtorType kind) {
@@ -2517,6 +2518,7 @@ static llvm::StringRef ClangToItaniumDtorKind(clang::CXXDtorType kind) {
25172518
case clang::CXXDtorType::Dtor_Comdat:
25182519
llvm_unreachable("Unexpected destructor kind.");
25192520
}
2521+
llvm_unreachable("Fully covered switch above");
25202522
}
25212523

25222524
static llvm::StringRef

0 commit comments

Comments
 (0)