Skip to content

Commit 68fbc8e

Browse files
committed
[lldb][NFC] Use UNUSED_IF_ASSERT_DISABLED instead of (void) cast
Uses of (void) remain where they are for purposes other than an assert variable.
1 parent ee9220c commit 68fbc8e

File tree

14 files changed

+20
-19
lines changed

14 files changed

+20
-19
lines changed

lldb/source/DataFormatters/StringPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ DecodedCharBuffer GetPrintableImpl<StringElementType::UTF8>(
183183
&buffer_for_conversion, buffer_end, &codepoint, llvm::strictConversion);
184184
assert(result == llvm::conversionOK &&
185185
"Failed to convert legal utf8 sequence");
186-
(void)result;
186+
UNUSED_IF_ASSERT_DISABLED(result);
187187

188188
// The UTF8 helper always advances by the utf8 encoded length.
189189
const unsigned utf8_encoded_len = buffer_for_conversion - buffer;

lldb/source/Expression/IRInterpreter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
15091509
size_t dataSize = 0;
15101510

15111511
bool Success = execution_unit.GetAllocSize(addr, dataSize);
1512-
(void)Success;
1512+
UNUSED_IF_ASSERT_DISABLED(Success);
15131513
assert(Success &&
15141514
"unable to locate host data for transfer to device");
15151515
// Create the required buffer

lldb/source/Host/common/PseudoTerminal.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ std::string PseudoTerminal::GetSecondaryName() const {
123123
char buf[PATH_MAX];
124124
buf[0] = '\0';
125125
int r = ptsname_r(m_primary_fd, buf, sizeof(buf));
126-
(void)r;
126+
UNUSED_IF_ASSERT_DISABLED(r);
127127
assert(r == 0);
128128
return buf;
129129
#if defined(__APPLE__)

lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ ConnectionFileDescriptor::BytesAvailable(const Timeout<std::micro> &timeout,
510510
ssize_t bytes_read =
511511
llvm::sys::RetryAfterSignal(-1, ::read, pipe_fd, &c, 1);
512512
assert(bytes_read == 1);
513-
(void)bytes_read;
513+
UNUSED_IF_ASSERT_DISABLED(bytes_read);
514514
switch (c) {
515515
case 'q':
516516
LLDB_LOGF(log,

lldb/source/Host/posix/MainLoopPosix.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ sigset_t MainLoopPosix::RunImpl::get_sigmask() {
122122
sigset_t sigmask;
123123
int ret = pthread_sigmask(SIG_SETMASK, nullptr, &sigmask);
124124
assert(ret == 0);
125-
(void)ret;
125+
UNUSED_IF_ASSERT_DISABLED(ret);
126126

127127
for (const auto &sig : loop.m_signals)
128128
sigdelset(&sigmask, sig.first);
@@ -299,7 +299,7 @@ MainLoopPosix::RegisterSignal(int signo, const Callback &callback,
299299
// Even if using kqueue, the signal handler will still be invoked, so it's
300300
// important to replace it with our "benign" handler.
301301
int ret = sigaction(signo, &new_action, &info.old_action);
302-
(void)ret;
302+
UNUSED_IF_ASSERT_DISABLED(ret);
303303
assert(ret == 0 && "sigaction failed");
304304

305305
#if HAVE_SYS_EVENT_H
@@ -346,7 +346,7 @@ void MainLoopPosix::UnregisterSignal(
346346
int ret = pthread_sigmask(it->second.was_blocked ? SIG_BLOCK : SIG_UNBLOCK,
347347
&set, nullptr);
348348
assert(ret == 0);
349-
(void)ret;
349+
UNUSED_IF_ASSERT_DISABLED(ret);
350350

351351
#if HAVE_SYS_EVENT_H
352352
struct kevent ev;

lldb/source/Host/windows/MainLoopWindows.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ MainLoopWindows::~MainLoopWindows() {
3030
assert(m_read_fds.empty());
3131
BOOL result = WSACloseEvent(m_trigger_event);
3232
assert(result == TRUE);
33-
(void)result;
33+
UNUSED_IF_ASSERT_DISABLED(result);
3434
}
3535

3636
llvm::Expected<size_t> MainLoopWindows::Poll() {
@@ -39,7 +39,7 @@ llvm::Expected<size_t> MainLoopWindows::Poll() {
3939
for (auto &[fd, info] : m_read_fds) {
4040
int result = WSAEventSelect(fd, info.event, FD_READ | FD_ACCEPT | FD_CLOSE);
4141
assert(result == 0);
42-
(void)result;
42+
UNUSED_IF_ASSERT_DISABLED(result);
4343

4444
events.push_back(info.event);
4545
}
@@ -51,7 +51,7 @@ llvm::Expected<size_t> MainLoopWindows::Poll() {
5151
for (auto &fd : m_read_fds) {
5252
int result = WSAEventSelect(fd.first, WSA_INVALID_EVENT, 0);
5353
assert(result == 0);
54-
(void)result;
54+
UNUSED_IF_ASSERT_DISABLED(result);
5555
}
5656

5757
if (result >= WSA_WAIT_EVENT_0 && result <= WSA_WAIT_EVENT_0 + events.size())
@@ -99,7 +99,7 @@ void MainLoopWindows::UnregisterReadObject(IOObject::WaitableHandle handle) {
9999
assert(it != m_read_fds.end());
100100
BOOL result = WSACloseEvent(it->second.event);
101101
assert(result == TRUE);
102-
(void)result;
102+
UNUSED_IF_ASSERT_DISABLED(result);
103103
m_read_fds.erase(it);
104104
}
105105

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ AppleObjCRuntimeV1::CreateObjectChecker(std::string name,
161161
" \n",
162162
name.c_str());
163163
assert(strformatsize < (int)sizeof(buf->contents));
164-
(void)strformatsize;
164+
UNUSED_IF_ASSERT_DISABLED(strformatsize);
165165

166166
return GetTargetRef().CreateUtilityFunction(buf->contents, std::move(name),
167167
eLanguageTypeC, exe_ctx);

lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "Plugins/ObjectFile/Breakpad/BreakpadRecords.h"
10+
#include "lldb/lldb-defines.h"
1011
#include "llvm/ADT/StringExtras.h"
1112
#include "llvm/ADT/StringSwitch.h"
1213
#include "llvm/Support/Endian.h"
@@ -119,7 +120,7 @@ static UUID parseModuleId(llvm::Triple::OSType os, llvm::StringRef str) {
119120
uint32_t age;
120121
bool success = to_integer(age_str, age, 16);
121122
assert(success);
122-
(void)success;
123+
UNUSED_IF_ASSERT_DISABLED(success);
123124
data.age = age;
124125

125126
// On non-windows, the age field should always be zero, so we don't include to

lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ NativeProcessFreeBSD::Manager::Launch(ProcessLaunchInfo &launch_info,
6969
int wstatus;
7070
::pid_t wpid = llvm::sys::RetryAfterSignal(-1, ::waitpid, pid, &wstatus, 0);
7171
assert(wpid == pid);
72-
(void)wpid;
72+
UNUSED_IF_ASSERT_DISABLED(wpid);
7373
if (!WIFSTOPPED(wstatus)) {
7474
LLDB_LOG(log, "Could not sync with inferior process: wstatus={1}",
7575
WaitStatus::Decode(wstatus));

lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ NativeProcessLinux::Manager::Launch(ProcessLaunchInfo &launch_info,
281281
int wstatus = 0;
282282
::pid_t wpid = llvm::sys::RetryAfterSignal(-1, ::waitpid, pid, &wstatus, 0);
283283
assert(wpid == pid);
284-
(void)wpid;
284+
UNUSED_IF_ASSERT_DISABLED(wpid);
285285
if (!WIFSTOPPED(wstatus)) {
286286
LLDB_LOG(log, "Could not sync with inferior process: wstatus={1}",
287287
WaitStatus::Decode(wstatus));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1762,7 +1762,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
17621762
}
17631763
}
17641764
assert(tag_decl_kind != -1);
1765-
(void)tag_decl_kind;
1765+
UNUSED_IF_ASSERT_DISABLED(tag_decl_kind);
17661766
bool clang_type_was_created = false;
17671767
clang_type = CompilerType(
17681768
m_ast.weak_from_this(),

lldb/source/Symbol/SymbolFile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ void SymbolFileCommon::SetCompileUnitAtIndex(uint32_t idx,
216216
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
217217
const size_t num_compile_units = GetNumCompileUnits();
218218
assert(idx < num_compile_units);
219-
(void)num_compile_units;
219+
UNUSED_IF_ASSERT_DISABLED(num_compile_units);
220220

221221
// Fire off an assertion if this compile unit already exists for now. The
222222
// partial parsing should take care of only setting the compile unit

lldb/source/Utility/Log.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ void Log::Warning(const char *format, ...) {
210210
void Log::Register(llvm::StringRef name, Channel &channel) {
211211
auto iter = g_channel_map->try_emplace(name, channel);
212212
assert(iter.second == true);
213-
(void)iter;
213+
UNUSED_IF_ASSERT_DISABLED(iter);
214214
}
215215

216216
void Log::Unregister(llvm::StringRef name) {

lldb/tools/lldb-dap/DAP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ DAP::DAP()
5757
int result = _setmode(fileno(stdout), _O_BINARY);
5858
assert(result);
5959
result = _setmode(fileno(stdin), _O_BINARY);
60-
(void)result;
60+
UNUSED_IF_ASSERT_DISABLED(result);
6161
assert(result);
6262
#endif
6363
if (log_file_path)

0 commit comments

Comments
 (0)