Include llvm/ADT/STLExtras.h from lldb/Utility/Utils.h and use llvm::array_lengthof(), instead.

llvm-svn: 156876
This commit is contained in:
Johnny Chen 2012-05-15 23:21:36 +00:00
parent 7a0d86be26
commit 6ebc8c4598
9 changed files with 16 additions and 14 deletions

View File

@ -10,11 +10,13 @@
#ifndef utility_Utils_h_
#define utility_Utils_h_
// These utilities have llvm namespace.
#include "llvm/ADT/STLExtras.h"
namespace lldb_private {
// Return the number of elements of a static array.
template <typename T, unsigned size>
inline unsigned arraysize(T (&v)[size]) { return size; }
// Add lldb utilities here.
} // namespace lldb_private
#endif // utility_Utils

View File

@ -36,7 +36,7 @@ g_option_table[] =
uint32_t
OptionGroupArchitecture::GetNumDefinitions ()
{
return arraysize(g_option_table);
return llvm::array_lengthof(g_option_table);
}
const OptionDefinition *

View File

@ -38,7 +38,7 @@ g_option_table[] =
uint32_t
OptionGroupOutputFile::GetNumDefinitions ()
{
return arraysize(g_option_table);
return llvm::array_lengthof(g_option_table);
}
const OptionDefinition *

View File

@ -99,8 +99,8 @@ uint32_t
OptionGroupPlatform::GetNumDefinitions ()
{
if (m_include_platform_option)
return arraysize(g_option_table);
return arraysize(g_option_table) - 1;
return llvm::array_lengthof(g_option_table);
return llvm::array_lengthof(g_option_table) - 1;
}

View File

@ -36,7 +36,7 @@ g_option_table[] =
uint32_t
OptionGroupUUID::GetNumDefinitions ()
{
return arraysize(g_option_table);
return llvm::array_lengthof(g_option_table);
}
const OptionDefinition *

View File

@ -49,7 +49,7 @@ g_option_table[] =
uint32_t
OptionGroupValueObjectDisplay::GetNumDefinitions ()
{
return arraysize(g_option_table);
return llvm::array_lengthof(g_option_table);
}
const OptionDefinition *

View File

@ -107,9 +107,9 @@ OptionGroupVariable::GetNumDefinitions ()
// Count the "--no-args", "--no-locals" and "--show-globals"
// options if we are showing frame specific options.
if (include_frame_options)
return arraysize(g_option_table);
return llvm::array_lengthof(g_option_table);
else
return arraysize(g_option_table) - NUM_FRAME_OPTS;
return llvm::array_lengthof(g_option_table) - NUM_FRAME_OPTS;
}

View File

@ -99,5 +99,5 @@ OptionGroupWatchpoint::GetDefinitions ()
uint32_t
OptionGroupWatchpoint::GetNumDefinitions ()
{
return arraysize(g_option_table);
return llvm::array_lengthof(g_option_table);
}

View File

@ -848,7 +848,7 @@ GDBRemoteDynamicRegisterInfo::HardcodeARMRegisters(bool from_scratch)
{ "q15", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q15, LLDB_INVALID_REGNUM, 106, 106 }, g_q15_regs, NULL}
};
static const uint32_t num_registers = arraysize(g_register_infos);
static const uint32_t num_registers = llvm::array_lengthof(g_register_infos);
static ConstString gpr_reg_set ("General Purpose Registers");
static ConstString sfp_reg_set ("Software Floating Point Registers");
static ConstString vfp_reg_set ("Floating Point Registers");
@ -900,7 +900,7 @@ GDBRemoteDynamicRegisterInfo::HardcodeARMRegisters(bool from_scratch)
else
{
// Add composite registers to our primordial registers, then.
const uint32_t num_composites = arraysize(g_composites);
const uint32_t num_composites = llvm::array_lengthof(g_composites);
const uint32_t num_primordials = GetNumRegisters();
RegisterInfo *g_comp_register_infos = g_register_infos + (num_registers - num_composites);
for (i=0; i<num_composites; ++i)