Skip to content

Commit

Permalink
[lldb][NFC] Use UNUSED_IF_ASSERT_DISABLED instead of (void) cast
Browse files Browse the repository at this point in the history
Uses of (void) remain where they are for purposes other than an
assert variable.
  • Loading branch information
DavidSpickett committed Nov 3, 2023
1 parent ee9220c commit 68fbc8e
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lldb/source/DataFormatters/StringPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ DecodedCharBuffer GetPrintableImpl<StringElementType::UTF8>(
&buffer_for_conversion, buffer_end, &codepoint, llvm::strictConversion);
assert(result == llvm::conversionOK &&
"Failed to convert legal utf8 sequence");
(void)result;
UNUSED_IF_ASSERT_DISABLED(result);

// The UTF8 helper always advances by the utf8 encoded length.
const unsigned utf8_encoded_len = buffer_for_conversion - buffer;
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Expression/IRInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
size_t dataSize = 0;

bool Success = execution_unit.GetAllocSize(addr, dataSize);
(void)Success;
UNUSED_IF_ASSERT_DISABLED(Success);
assert(Success &&
"unable to locate host data for transfer to device");
// Create the required buffer
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Host/common/PseudoTerminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ std::string PseudoTerminal::GetSecondaryName() const {
char buf[PATH_MAX];
buf[0] = '\0';
int r = ptsname_r(m_primary_fd, buf, sizeof(buf));
(void)r;
UNUSED_IF_ASSERT_DISABLED(r);
assert(r == 0);
return buf;
#if defined(__APPLE__)
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ ConnectionFileDescriptor::BytesAvailable(const Timeout<std::micro> &timeout,
ssize_t bytes_read =
llvm::sys::RetryAfterSignal(-1, ::read, pipe_fd, &c, 1);
assert(bytes_read == 1);
(void)bytes_read;
UNUSED_IF_ASSERT_DISABLED(bytes_read);
switch (c) {
case 'q':
LLDB_LOGF(log,
Expand Down
6 changes: 3 additions & 3 deletions lldb/source/Host/posix/MainLoopPosix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ sigset_t MainLoopPosix::RunImpl::get_sigmask() {
sigset_t sigmask;
int ret = pthread_sigmask(SIG_SETMASK, nullptr, &sigmask);
assert(ret == 0);
(void)ret;
UNUSED_IF_ASSERT_DISABLED(ret);

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

#if HAVE_SYS_EVENT_H
Expand Down Expand Up @@ -346,7 +346,7 @@ void MainLoopPosix::UnregisterSignal(
int ret = pthread_sigmask(it->second.was_blocked ? SIG_BLOCK : SIG_UNBLOCK,
&set, nullptr);
assert(ret == 0);
(void)ret;
UNUSED_IF_ASSERT_DISABLED(ret);

#if HAVE_SYS_EVENT_H
struct kevent ev;
Expand Down
8 changes: 4 additions & 4 deletions lldb/source/Host/windows/MainLoopWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ MainLoopWindows::~MainLoopWindows() {
assert(m_read_fds.empty());
BOOL result = WSACloseEvent(m_trigger_event);
assert(result == TRUE);
(void)result;
UNUSED_IF_ASSERT_DISABLED(result);
}

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

events.push_back(info.event);
}
Expand All @@ -51,7 +51,7 @@ llvm::Expected<size_t> MainLoopWindows::Poll() {
for (auto &fd : m_read_fds) {
int result = WSAEventSelect(fd.first, WSA_INVALID_EVENT, 0);
assert(result == 0);
(void)result;
UNUSED_IF_ASSERT_DISABLED(result);
}

if (result >= WSA_WAIT_EVENT_0 && result <= WSA_WAIT_EVENT_0 + events.size())
Expand Down Expand Up @@ -99,7 +99,7 @@ void MainLoopWindows::UnregisterReadObject(IOObject::WaitableHandle handle) {
assert(it != m_read_fds.end());
BOOL result = WSACloseEvent(it->second.event);
assert(result == TRUE);
(void)result;
UNUSED_IF_ASSERT_DISABLED(result);
m_read_fds.erase(it);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ AppleObjCRuntimeV1::CreateObjectChecker(std::string name,
" \n",
name.c_str());
assert(strformatsize < (int)sizeof(buf->contents));
(void)strformatsize;
UNUSED_IF_ASSERT_DISABLED(strformatsize);

return GetTargetRef().CreateUtilityFunction(buf->contents, std::move(name),
eLanguageTypeC, exe_ctx);
Expand Down
3 changes: 2 additions & 1 deletion lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

#include "Plugins/ObjectFile/Breakpad/BreakpadRecords.h"
#include "lldb/lldb-defines.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/Endian.h"
Expand Down Expand Up @@ -119,7 +120,7 @@ static UUID parseModuleId(llvm::Triple::OSType os, llvm::StringRef str) {
uint32_t age;
bool success = to_integer(age_str, age, 16);
assert(success);
(void)success;
UNUSED_IF_ASSERT_DISABLED(success);
data.age = age;

// On non-windows, the age field should always be zero, so we don't include to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ NativeProcessFreeBSD::Manager::Launch(ProcessLaunchInfo &launch_info,
int wstatus;
::pid_t wpid = llvm::sys::RetryAfterSignal(-1, ::waitpid, pid, &wstatus, 0);
assert(wpid == pid);
(void)wpid;
UNUSED_IF_ASSERT_DISABLED(wpid);
if (!WIFSTOPPED(wstatus)) {
LLDB_LOG(log, "Could not sync with inferior process: wstatus={1}",
WaitStatus::Decode(wstatus));
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ NativeProcessLinux::Manager::Launch(ProcessLaunchInfo &launch_info,
int wstatus = 0;
::pid_t wpid = llvm::sys::RetryAfterSignal(-1, ::waitpid, pid, &wstatus, 0);
assert(wpid == pid);
(void)wpid;
UNUSED_IF_ASSERT_DISABLED(wpid);
if (!WIFSTOPPED(wstatus)) {
LLDB_LOG(log, "Could not sync with inferior process: wstatus={1}",
WaitStatus::Decode(wstatus));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1762,7 +1762,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
}
}
assert(tag_decl_kind != -1);
(void)tag_decl_kind;
UNUSED_IF_ASSERT_DISABLED(tag_decl_kind);
bool clang_type_was_created = false;
clang_type = CompilerType(
m_ast.weak_from_this(),
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Symbol/SymbolFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ void SymbolFileCommon::SetCompileUnitAtIndex(uint32_t idx,
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
const size_t num_compile_units = GetNumCompileUnits();
assert(idx < num_compile_units);
(void)num_compile_units;
UNUSED_IF_ASSERT_DISABLED(num_compile_units);

// Fire off an assertion if this compile unit already exists for now. The
// partial parsing should take care of only setting the compile unit
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Utility/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void Log::Warning(const char *format, ...) {
void Log::Register(llvm::StringRef name, Channel &channel) {
auto iter = g_channel_map->try_emplace(name, channel);
assert(iter.second == true);
(void)iter;
UNUSED_IF_ASSERT_DISABLED(iter);
}

void Log::Unregister(llvm::StringRef name) {
Expand Down
2 changes: 1 addition & 1 deletion lldb/tools/lldb-dap/DAP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ DAP::DAP()
int result = _setmode(fileno(stdout), _O_BINARY);
assert(result);
result = _setmode(fileno(stdin), _O_BINARY);
(void)result;
UNUSED_IF_ASSERT_DISABLED(result);
assert(result);
#endif
if (log_file_path)
Expand Down

0 comments on commit 68fbc8e

Please sign in to comment.