[Lldb-commits] [lldb] r243074 - Add UNUSED_IF_ASSERT_DISABLED and apply it.

Bruce Mitchener bruce.mitchener at gmail.com
Thu Jul 23 17:23:30 PDT 2015


Author: brucem
Date: Thu Jul 23 19:23:29 2015
New Revision: 243074

URL: http://llvm.org/viewvc/llvm-project?rev=243074&view=rev
Log:
Add UNUSED_IF_ASSERT_DISABLED and apply it.

Summary:
This replaces (void)x; usages where they x was subsequently
involved in an assertion with this macro to make the
intent more clear.

Reviewers: clayborg

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D11451

Modified:
    lldb/trunk/include/lldb/lldb-defines.h
    lldb/trunk/source/Host/posix/MainLoopPosix.cpp
    lldb/trunk/source/Interpreter/CommandInterpreter.cpp
    lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
    lldb/trunk/source/Symbol/ClangASTImporter.cpp
    lldb/trunk/source/Target/Process.cpp
    lldb/trunk/tools/debugserver/source/DNB.cpp
    lldb/trunk/tools/debugserver/source/DNBDefs.h
    lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm
    lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp
    lldb/trunk/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
    lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp
    lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp

Modified: lldb/trunk/include/lldb/lldb-defines.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-defines.h?rev=243074&r1=243073&r2=243074&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-defines.h (original)
+++ lldb/trunk/include/lldb/lldb-defines.h Thu Jul 23 19:23:29 2015
@@ -137,6 +137,8 @@
 #define __attribute__(X)
 #endif
 
+#define UNUSED_IF_ASSERT_DISABLED(x) ((void)(x))
+
 #if defined(__cplusplus)
 
 //----------------------------------------------------------------------

Modified: lldb/trunk/source/Host/posix/MainLoopPosix.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/posix/MainLoopPosix.cpp?rev=243074&r1=243073&r2=243074&view=diff
==============================================================================
--- lldb/trunk/source/Host/posix/MainLoopPosix.cpp (original)
+++ lldb/trunk/source/Host/posix/MainLoopPosix.cpp Thu Jul 23 19:23:29 2015
@@ -97,7 +97,7 @@ void
 MainLoopPosix::UnregisterReadObject(IOObject::WaitableHandle handle)
 {
     bool erased = m_read_fds.erase(handle);
-    (void) erased;
+    UNUSED_IF_ASSERT_DISABLED(erased);
     assert(erased);
 }
 

Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=243074&r1=243073&r2=243074&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Thu Jul 23 19:23:29 2015
@@ -511,8 +511,7 @@ CommandInterpreter::LoadCommandDictionar
             char buffer[1024];
             int num_printed = snprintf(buffer, 1024, "%s %s", break_regexes[i][1], "-o");
             assert (num_printed < 1024);
-	    // Quiet unused variable warning for release builds.
-	    (void) num_printed;
+            UNUSED_IF_ASSERT_DISABLED(num_printed);
             success = tbreak_regex_cmd_ap->AddRegexCommand (break_regexes[i][0], buffer);
             if (!success)
                 break;

Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=243074&r1=243073&r2=243074&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Thu Jul 23 19:23:29 2015
@@ -718,7 +718,7 @@ DynamicLoaderMacOSXDYLD::ReadAllImageInf
         const size_t count_v13 = count_v11 +
                                  addr_size +         // sharedCacheSlide
                                  sizeof (uuid_t);    // sharedCacheUUID
-        (void) count_v13; // Avoid warnings when assertions are off.
+        UNUSED_IF_ASSERT_DISABLED(count_v13);
         assert (sizeof (buf) >= count_v13);
 
         Error error;

Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp?rev=243074&r1=243073&r2=243074&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp Thu Jul 23 19:23:29 2015
@@ -44,7 +44,7 @@ AppleObjCTypeEncodingParser::ReadQuotedS
     while (type.HasAtLeast(1) && type.Peek() != '"')
         buffer.Printf("%c",type.Next());
     StringLexer::Character next = type.Next();
-    (void) next; // Avoid warnings when assertions are off.
+    UNUSED_IF_ASSERT_DISABLED(next);
     assert (next == '"');
     return buffer.GetString();
 }

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp?rev=243074&r1=243073&r2=243074&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp Thu Jul 23 19:23:29 2015
@@ -133,7 +133,7 @@ GDBRemoteCommunicationServerPlatform::Ha
     int platform_port;
     std::string platform_path;
     bool ok = UriParser::Parse(GetConnection()->GetURI().c_str(), platform_scheme, platform_ip, platform_port, platform_path);
-    (void)ok;
+    UNUSED_IF_ASSERT_DISABLED(ok);
     assert(ok);
     Error error = StartDebugserverProcess (
                                      platform_ip.c_str(),

Modified: lldb/trunk/source/Symbol/ClangASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTImporter.cpp?rev=243074&r1=243073&r2=243074&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTImporter.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTImporter.cpp Thu Jul 23 19:23:29 2015
@@ -623,7 +623,7 @@ ClangASTImporter::Minion::ExecuteDeportW
         m_decls_to_deport->erase(decl);
         
         DeclOrigin &origin = to_context_md->m_origins[decl];
-        (void)origin;
+        UNUSED_IF_ASSERT_DISABLED(origin);
         
         assert (origin.ctx == m_source_ctx);    // otherwise we should never have added this
                                                 // because it doesn't need to be deported

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=243074&r1=243073&r2=243074&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Thu Jul 23 19:23:29 2015
@@ -2843,7 +2843,7 @@ Process::WriteMemory (addr_t addr, const
                     size_t intersect_size;
                     size_t opcode_offset;
                     const bool intersects = bp->IntersectsRange(addr, size, &intersect_addr, &intersect_size, &opcode_offset);
-                    (void)intersects;
+                    UNUSED_IF_ASSERT_DISABLED(intersects);
                     assert(intersects);
                     assert(addr <= intersect_addr && intersect_addr < addr + size);
                     assert(addr < intersect_addr + intersect_size && intersect_addr + intersect_size <= addr + size);

Modified: lldb/trunk/tools/debugserver/source/DNB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNB.cpp?rev=243074&r1=243073&r2=243074&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/DNB.cpp (original)
+++ lldb/trunk/tools/debugserver/source/DNB.cpp Thu Jul 23 19:23:29 2015
@@ -446,7 +446,7 @@ DNBProcessLaunch (const char *path,
             else
             {
                 bool res = AddProcessToMap(pid, processSP);
-                (void)res;
+                UNUSED_IF_ASSERT_DISABLED(res);
                 assert(res && "Couldn't add process to map!");
                 return pid;
             }
@@ -495,7 +495,7 @@ DNBProcessAttach (nub_process_t attach_p
         if (pid != INVALID_NUB_PROCESS)
         {
             bool res = AddProcessToMap(pid, processSP);
-            (void)res;
+            UNUSED_IF_ASSERT_DISABLED(res);
             assert(res && "Couldn't add process to map!");
             spawn_waitpid_thread(pid);
         }

Modified: lldb/trunk/tools/debugserver/source/DNBDefs.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNBDefs.h?rev=243074&r1=243073&r2=243074&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/DNBDefs.h (original)
+++ lldb/trunk/tools/debugserver/source/DNBDefs.h Thu Jul 23 19:23:29 2015
@@ -365,4 +365,6 @@ typedef nub_addr_t (*DNBCallbackNameToAd
 typedef nub_size_t (*DNBCallbackCopyExecutableImageInfos)(nub_process_t pid, struct DNBExecutableImageInfo **image_infos, nub_bool_t only_changed, void *baton);
 typedef void (*DNBCallbackLog)(void *baton, uint32_t flags, const char *format, va_list args);
 
+#define UNUSED_IF_ASSERT_DISABLED(x) ((void)(x))
+
 #endif    // #ifndef __DNBDefs_h__

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm?rev=243074&r1=243073&r2=243074&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm Thu Jul 23 19:23:29 2015
@@ -1032,7 +1032,7 @@ MachProcess::WriteMemory (nub_addr_t add
         DNBBreakpoint *bp = bps[i];
 
         const bool intersects = bp->IntersectsRange(addr, size, &intersect_addr, &intersect_size, &opcode_offset);
-        (void)intersects;
+        UNUSED_IF_ASSERT_DISABLED(intersects);
         assert(intersects);
         assert(addr <= intersect_addr && intersect_addr < addr + size);
         assert(addr < intersect_addr + intersect_size && intersect_addr + intersect_size <= addr + size);

Modified: lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp?rev=243074&r1=243073&r2=243074&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp Thu Jul 23 19:23:29 2015
@@ -2060,7 +2060,7 @@ DNBArchMachARM::GetRegisterContext (void
         p += sizeof(m_state.context.exc);
 
         size_t bytes_written = p - (uint8_t *)buf;
-        (void)bytes_written;
+        UNUSED_IF_ASSERT_DISABLED(bytes_written);
         assert (bytes_written == size);
 
     }
@@ -2094,7 +2094,7 @@ DNBArchMachARM::SetRegisterContext (cons
         p += sizeof(m_state.context.exc);
         
         size_t bytes_written = p - (uint8_t *)buf;
-        (void)bytes_written;
+        UNUSED_IF_ASSERT_DISABLED(bytes_written);
         assert (bytes_written == size);
 
         if (SetGPRState() | SetVFPState() | SetEXCState())

Modified: lldb/trunk/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp?rev=243074&r1=243073&r2=243074&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp Thu Jul 23 19:23:29 2015
@@ -1995,7 +1995,7 @@ DNBArchMachARM64::GetRegisterContext (vo
         p += sizeof(m_state.context.exc);
         
         size_t bytes_written = p - (uint8_t *)buf;
-        (void)bytes_written;
+        UNUSED_IF_ASSERT_DISABLED(bytes_written);
         assert (bytes_written == size);
     }
     DNBLogThreadedIf (LOG_THREAD, "DNBArchMachARM64::GetRegisterContext (buf = %p, len = %zu) => %zu", buf, buf_len, size);
@@ -2028,7 +2028,7 @@ DNBArchMachARM64::SetRegisterContext (co
         p += sizeof(m_state.context.exc);
         
         size_t bytes_written = p - (uint8_t *)buf;
-        (void)bytes_written;
+        UNUSED_IF_ASSERT_DISABLED(bytes_written);
         assert (bytes_written == size);
         SetGPRState();
         SetVFPState();

Modified: lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp?rev=243074&r1=243073&r2=243074&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp Thu Jul 23 19:23:29 2015
@@ -1703,7 +1703,7 @@ DNBArchImplI386::GetRegisterContext (voi
             
             // make sure we end up with exactly what we think we should have
             size_t bytes_written = p - (uint8_t *)buf;
-            (void)bytes_written;
+            UNUSED_IF_ASSERT_DISABLED(bytes_written);
             assert (bytes_written == size);
         }
     }
@@ -1789,7 +1789,7 @@ DNBArchImplI386::SetRegisterContext (con
         
         // make sure we end up with exactly what we think we should have
         size_t bytes_written = p - (uint8_t *)buf;
-        (void)bytes_written;
+        UNUSED_IF_ASSERT_DISABLED(bytes_written);
         assert (bytes_written == size);
         kern_return_t kret;
         if ((kret = SetGPRState()) != KERN_SUCCESS)

Modified: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp?rev=243074&r1=243073&r2=243074&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp Thu Jul 23 19:23:29 2015
@@ -2089,7 +2089,7 @@ DNBArchImplX86_64::GetRegisterContext (v
             
             // make sure we end up with exactly what we think we should have
             size_t bytes_written = p - (uint8_t *)buf;
-            (void)bytes_written;
+            UNUSED_IF_ASSERT_DISABLED(bytes_written);
             assert (bytes_written == size);
         }
 
@@ -2177,7 +2177,7 @@ DNBArchImplX86_64::SetRegisterContext (c
         
         // make sure we end up with exactly what we think we should have
         size_t bytes_written = p - (uint8_t *)buf;
-        (void)bytes_written;
+        UNUSED_IF_ASSERT_DISABLED(bytes_written);
         assert (bytes_written == size);
 
         kern_return_t kret;





More information about the lldb-commits mailing list