[Lldb-commits] [lldb] r360753 - Replace assert with static_assert here applicable.

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Tue May 14 22:39:41 PDT 2019


Author: jdevlieghere
Date: Tue May 14 22:39:41 2019
New Revision: 360753

URL: http://llvm.org/viewvc/llvm-project?rev=360753&view=rev
Log:
Replace assert with static_assert here applicable.

Replaces assert() with static_assert() if the condition is can be
evaluated at compile time.

Modified:
    lldb/trunk/source/Expression/IRExecutionUnit.cpp
    lldb/trunk/source/Interpreter/CommandObject.cpp
    lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
    lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp
    lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.cpp

Modified: lldb/trunk/source/Expression/IRExecutionUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRExecutionUnit.cpp?rev=360753&r1=360752&r2=360753&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRExecutionUnit.cpp (original)
+++ lldb/trunk/source/Expression/IRExecutionUnit.cpp Tue May 14 22:39:41 2019
@@ -1023,7 +1023,7 @@ IRExecutionUnit::MemoryManager::getSymbo
 
 void *IRExecutionUnit::MemoryManager::getPointerToNamedFunction(
     const std::string &Name, bool AbortOnFailure) {
-  assert(sizeof(void *) == 8);
+  static_assert(sizeof(void *) == 8, "");
 
   return (void *)getSymbolAddress(Name);
 }

Modified: lldb/trunk/source/Interpreter/CommandObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=360753&r1=360752&r2=360753&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandObject.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandObject.cpp Tue May 14 22:39:41 2019
@@ -1103,7 +1103,8 @@ CommandObject::ArgumentTableEntry Comman
 const CommandObject::ArgumentTableEntry *CommandObject::GetArgumentTable() {
   // If this assertion fires, then the table above is out of date with the
   // CommandArgumentType enumeration
-  assert((sizeof(CommandObject::g_arguments_data) /
-          sizeof(CommandObject::ArgumentTableEntry)) == eArgTypeLastArg);
+  static_assert((sizeof(CommandObject::g_arguments_data) /
+                 sizeof(CommandObject::ArgumentTableEntry)) == eArgTypeLastArg,
+                "");
   return CommandObject::g_arguments_data;
 }

Modified: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=360753&r1=360752&r2=360753&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp Tue May 14 22:39:41 2019
@@ -1972,8 +1972,8 @@ bool RenderScriptRuntime::JITTypePacked(
 
   // We want 4 elements from packed data
   const uint32_t num_exprs = 4;
-  assert(num_exprs == (eExprTypeElemPtr - eExprTypeDimX + 1) &&
-         "Invalid number of expressions");
+  static_assert(num_exprs == (eExprTypeElemPtr - eExprTypeDimX + 1),
+                "Invalid number of expressions");
 
   char expr_bufs[num_exprs][jit_max_expr_size];
   uint64_t results[num_exprs];
@@ -2031,8 +2031,8 @@ bool RenderScriptRuntime::JITElementPack
 
   // We want 4 elements from packed data
   const uint32_t num_exprs = 4;
-  assert(num_exprs == (eExprElementFieldCount - eExprElementType + 1) &&
-         "Invalid number of expressions");
+  static_assert(num_exprs == (eExprElementFieldCount - eExprElementType + 1),
+                "Invalid number of expressions");
 
   char expr_bufs[num_exprs][jit_max_expr_size];
   uint64_t results[num_exprs];
@@ -2090,8 +2090,8 @@ bool RenderScriptRuntime::JITSubelements
   }
 
   const short num_exprs = 3;
-  assert(num_exprs == (eExprSubelementsArrSize - eExprSubelementsId + 1) &&
-         "Invalid number of expressions");
+  static_assert(num_exprs == (eExprSubelementsArrSize - eExprSubelementsId + 1),
+                "Invalid number of expressions");
 
   char expr_buffer[jit_max_expr_size];
   uint64_t results;

Modified: lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp?rev=360753&r1=360752&r2=360753&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp Tue May 14 22:39:41 2019
@@ -782,7 +782,7 @@ RegisterContextMinidump_ARM64::RegisterC
   auto regs_data = data.GetData(&offset, sizeof(m_regs.v));
   if (regs_data)
     memcpy(m_regs.v, regs_data, sizeof(m_regs.v));
-  assert(k_num_regs == k_num_reg_infos);
+  static_assert(k_num_regs == k_num_reg_infos, "");
 }
 size_t RegisterContextMinidump_ARM64::GetRegisterCount() { return k_num_regs; }
 

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.cpp?rev=360753&r1=360752&r2=360753&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.cpp Tue May 14 22:39:41 2019
@@ -122,7 +122,7 @@ bool MachVMRegion::GetRegionForAddress(n
   m_start = addr;
   m_depth = 1024;
   mach_msg_type_number_t info_size = kRegionInfoSize;
-  assert(sizeof(info_size) == 4);
+  static_assert(sizeof(info_size) == 4, "");
   m_err =
       ::mach_vm_region_recurse(m_task, &m_start, &m_size, &m_depth,
                                (vm_region_recurse_info_t)&m_data, &info_size);




More information about the lldb-commits mailing list