diff --git a/lldb/source/DataFormatters/StringPrinter.cpp b/lldb/source/DataFormatters/StringPrinter.cpp index 4b57e87b4ccdcd..ab07c74fd1854b 100644 --- a/lldb/source/DataFormatters/StringPrinter.cpp +++ b/lldb/source/DataFormatters/StringPrinter.cpp @@ -183,7 +183,7 @@ DecodedCharBuffer GetPrintableImpl( &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; diff --git a/lldb/source/Expression/IRInterpreter.cpp b/lldb/source/Expression/IRInterpreter.cpp index 10457f51a95d8b..df029227086639 100644 --- a/lldb/source/Expression/IRInterpreter.cpp +++ b/lldb/source/Expression/IRInterpreter.cpp @@ -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 diff --git a/lldb/source/Host/common/PseudoTerminal.cpp b/lldb/source/Host/common/PseudoTerminal.cpp index de49058beeb703..d53327973eb270 100644 --- a/lldb/source/Host/common/PseudoTerminal.cpp +++ b/lldb/source/Host/common/PseudoTerminal.cpp @@ -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__) diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp index 6a367a3307e543..fceeff08ed9d36 100644 --- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp +++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp @@ -510,7 +510,7 @@ ConnectionFileDescriptor::BytesAvailable(const Timeout &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, diff --git a/lldb/source/Host/posix/MainLoopPosix.cpp b/lldb/source/Host/posix/MainLoopPosix.cpp index 5b50b450433ea8..5fe4d015251c8a 100644 --- a/lldb/source/Host/posix/MainLoopPosix.cpp +++ b/lldb/source/Host/posix/MainLoopPosix.cpp @@ -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); @@ -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 @@ -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; diff --git a/lldb/source/Host/windows/MainLoopWindows.cpp b/lldb/source/Host/windows/MainLoopWindows.cpp index 6e5f45d98208e1..25ea305c997635 100644 --- a/lldb/source/Host/windows/MainLoopWindows.cpp +++ b/lldb/source/Host/windows/MainLoopWindows.cpp @@ -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 MainLoopWindows::Poll() { @@ -39,7 +39,7 @@ llvm::Expected 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); } @@ -51,7 +51,7 @@ llvm::Expected 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()) @@ -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); } diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp index 65f00f5e4d0220..93168c23f3547b 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp @@ -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); diff --git a/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp b/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp index b0afe039462207..d40f87b1a7b423 100644 --- a/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp +++ b/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp @@ -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" @@ -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 diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp b/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp index 84a009be50bf48..19e0986ace31ff 100644 --- a/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp +++ b/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp @@ -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)); diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp index aac3bc847dd051..5d2b4b03fe60cb 100644 --- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -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)); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 28057185603575..696708d3fc7cf5 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -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(), diff --git a/lldb/source/Symbol/SymbolFile.cpp b/lldb/source/Symbol/SymbolFile.cpp index 7dcee8ced0ea11..4b9c3863e46159 100644 --- a/lldb/source/Symbol/SymbolFile.cpp +++ b/lldb/source/Symbol/SymbolFile.cpp @@ -216,7 +216,7 @@ void SymbolFileCommon::SetCompileUnitAtIndex(uint32_t idx, std::lock_guard 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 diff --git a/lldb/source/Utility/Log.cpp b/lldb/source/Utility/Log.cpp index 75912683e2334b..3a45a0285d3e25 100644 --- a/lldb/source/Utility/Log.cpp +++ b/lldb/source/Utility/Log.cpp @@ -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) { diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp index 6fa0514bfe32bd..1bff198e4ac000 100644 --- a/lldb/tools/lldb-dap/DAP.cpp +++ b/lldb/tools/lldb-dap/DAP.cpp @@ -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)