[Lldb-commits] [lldb] r211868 - lldb: remove adhoc implementation of array_sizeof

Saleem Abdulrasool compnerd at compnerd.org
Fri Jun 27 21:30:44 PDT 2014


On Fri, Jun 27, 2014 at 9:12 AM, <jingham at apple.com> wrote:

> Hey, Saleem.
>
> I reverted the debugserver part of this change.  Debugserver doesn't
> currently depend on llvm (actually it really doesn't depend on lldb either)
> and
> I'd rather not add that dependence unless there's some strong reason.
>

Sure, thats fine.


> Jim
>
> > On Jun 26, 2014, at 10:17 PM, Saleem Abdulrasool <compnerd at compnerd.org>
> wrote:
> >
> > Author: compnerd
> > Date: Fri Jun 27 00:17:41 2014
> > New Revision: 211868
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=211868&view=rev
> > Log:
> > lldb: remove adhoc implementation of array_sizeof
> >
> > Replace adhoc inline implementation of llvm::array_lengthof in favour of
> the
> > implementation in LLVM.  This is simply a cleanup change, no functional
> change
> > intended.
> >
> > Modified:
> >    lldb/trunk/source/Commands/CommandObjectExpression.cpp
> >    lldb/trunk/source/Commands/CommandObjectRegister.cpp
> >    lldb/trunk/source/Core/ArchSpec.cpp
> >    lldb/trunk/source/Core/Language.cpp
> >    lldb/trunk/source/DataFormatters/FormatManager.cpp
> >    lldb/trunk/source/Host/common/Host.cpp
> >    lldb/trunk/source/Host/common/Terminal.cpp
> >    lldb/trunk/source/Interpreter/CommandInterpreter.cpp
> >    lldb/trunk/source/Interpreter/OptionValueBoolean.cpp
> >    lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
> >    lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
> >    lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
> >    lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
> >    lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
> >
>  lldb/trunk/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
> >    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
> >
>  lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
> >
>  lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
> >
>  lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp
> >
>  lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
> >
>  lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
> >    lldb/trunk/source/Utility/SharingPtr.cpp
> >    lldb/trunk/tools/debugserver/source/DNB.cpp
> >    lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp
> >    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/ppc/DNBArchImpl.cpp
> >
>  lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
> >    lldb/trunk/tools/debugserver/source/TTYState.h
> >    lldb/trunk/tools/lldb-perf/common/clang/lldb_perf_clang.cpp
> >
> > Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original)
> > +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Fri Jun 27
> 00:17:41 2014
> > @@ -34,6 +34,7 @@
> > #include "lldb/Target/StackFrame.h"
> > #include "lldb/Target/Target.h"
> > #include "lldb/Target/Thread.h"
> > +#include "llvm/ADT/STLExtras.h"
> > #include "llvm/ADT/StringRef.h"
> >
> > using namespace lldb;
> > @@ -71,7 +72,7 @@ CommandObjectExpression::CommandOptions:
> > uint32_t
> > CommandObjectExpression::CommandOptions::GetNumDefinitions ()
> > {
> > -    return sizeof(g_option_table)/sizeof(OptionDefinition);
> > +    return llvm::array_lengthof(g_option_table);
> > }
> >
> > Error
> >
> > Modified: lldb/trunk/source/Commands/CommandObjectRegister.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRegister.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > --- lldb/trunk/source/Commands/CommandObjectRegister.cpp (original)
> > +++ lldb/trunk/source/Commands/CommandObjectRegister.cpp Fri Jun 27
> 00:17:41 2014
> > @@ -31,6 +31,7 @@
> > #include "lldb/Target/RegisterContext.h"
> > #include "lldb/Target/SectionLoadList.h"
> > #include "lldb/Target/Thread.h"
> > +#include "llvm/ADT/STLExtras.h"
> >
> > using namespace lldb;
> > using namespace lldb_private;
> > @@ -360,7 +361,7 @@ CommandObjectRegisterRead::CommandOption
> > uint32_t
> > CommandObjectRegisterRead::CommandOptions::GetNumDefinitions ()
> > {
> > -    return sizeof(g_option_table)/sizeof(OptionDefinition);
> > +    return llvm::array_lengthof(g_option_table);
> > }
> >
> >
> >
> > Modified: lldb/trunk/source/Core/ArchSpec.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > --- lldb/trunk/source/Core/ArchSpec.cpp (original)
> > +++ lldb/trunk/source/Core/ArchSpec.cpp Fri Jun 27 00:17:41 2014
> > @@ -14,6 +14,7 @@
> >
> > #include <string>
> >
> > +#include "llvm/ADT/STLExtras.h"
> > #include "llvm/Support/COFF.h"
> > #include "llvm/Support/ELF.h"
> > #include "llvm/Support/Host.h"
> > @@ -227,7 +228,7 @@ static const ArchDefinitionEntry g_macho
> > };
> > static const ArchDefinition g_macho_arch_def = {
> >     eArchTypeMachO,
> > -    sizeof(g_macho_arch_entries)/sizeof(g_macho_arch_entries[0]),
> > +    llvm::array_lengthof(g_macho_arch_entries),
> >     g_macho_arch_entries,
> >     "mach-o"
> > };
> > @@ -253,7 +254,7 @@ static const ArchDefinitionEntry g_elf_a
> >
> > static const ArchDefinition g_elf_arch_def = {
> >     eArchTypeELF,
> > -    sizeof(g_elf_arch_entries)/sizeof(g_elf_arch_entries[0]),
> > +    llvm::array_lengthof(g_elf_arch_entries),
> >     g_elf_arch_entries,
> >     "elf",
> > };
> > @@ -271,7 +272,7 @@ static const ArchDefinitionEntry g_coff_
> >
> > static const ArchDefinition g_coff_arch_def = {
> >     eArchTypeCOFF,
> > -    sizeof(g_coff_arch_entries)/sizeof(g_coff_arch_entries[0]),
> > +    llvm::array_lengthof(g_coff_arch_entries),
> >     g_coff_arch_entries,
> >     "pe-coff",
> > };
> > @@ -284,8 +285,7 @@ static const ArchDefinition *g_arch_defi
> >     &g_coff_arch_def
> > };
> >
> > -static const size_t k_num_arch_definitions =
> > -    sizeof(g_arch_definitions) / sizeof(g_arch_definitions[0]);
> > +static const size_t k_num_arch_definitions =
> llvm::array_lengthof(g_arch_definitions);
> >
> >
> //===----------------------------------------------------------------------===//
> > // Static helper functions.
> >
> > Modified: lldb/trunk/source/Core/Language.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Language.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > --- lldb/trunk/source/Core/Language.cpp (original)
> > +++ lldb/trunk/source/Core/Language.cpp Fri Jun 27 00:17:41 2014
> > @@ -10,6 +10,7 @@
> > #include "lldb/lldb-private.h"
> > #include "lldb/Core/Language.h"
> > #include "lldb/Core/Stream.h"
> > +#include "llvm/ADT/STLExtras.h"
> > #include <string.h>
> >
> > using namespace lldb;
> > @@ -48,8 +49,7 @@ g_languages[] =
> >     { { "python"  , NULL          , "Python"              } }
> > };
> >
> > -static const size_t
> > -g_num_languages = sizeof(g_languages)/sizeof(LanguageStrings);
> > +static const size_t g_num_languages = llvm::array_lengthof(g_languages);
> >
> > Language::Language(LanguageType language) :
> >     m_language (language)
> >
> > Modified: lldb/trunk/source/DataFormatters/FormatManager.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatManager.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > --- lldb/trunk/source/DataFormatters/FormatManager.cpp (original)
> > +++ lldb/trunk/source/DataFormatters/FormatManager.cpp Fri Jun 27
> 00:17:41 2014
> > @@ -21,6 +21,7 @@
> > #include "lldb/Interpreter/ScriptInterpreterPython.h"
> > #include "lldb/Target/ExecutionContext.h"
> > #include "lldb/Target/Platform.h"
> > +#include "llvm/ADT/STLExtras.h"
> >
> > using namespace lldb;
> > using namespace lldb_private;
> > @@ -76,8 +77,7 @@ g_format_infos[] =
> >     { eFormatVoid           , 'v'   , "void"                }
> > };
> >
> > -static uint32_t
> > -g_num_format_infos = sizeof(g_format_infos)/sizeof(FormatInfo);
> > +static uint32_t g_num_format_infos =
> llvm::array_lengthof(g_format_infos);
> >
> > static bool
> > GetFormatFromFormatChar (char format_char, Format &format)
> >
> > Modified: lldb/trunk/source/Host/common/Host.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > --- lldb/trunk/source/Host/common/Host.cpp (original)
> > +++ lldb/trunk/source/Host/common/Host.cpp Fri Jun 27 00:17:41 2014
> > @@ -66,6 +66,7 @@
> > #include "lldb/Target/TargetList.h"
> > #include "lldb/Utility/CleanUp.h"
> >
> > +#include "llvm/ADT/STLExtras.h"
> > #include "llvm/ADT/SmallString.h"
> > #include "llvm/Support/Host.h"
> > #include "llvm/Support/raw_ostream.h"
> > @@ -2063,7 +2064,7 @@ Host::GetNumberCPUS ()
> > #endif
> >
> >         /* get the number of CPUs from the system */
> > -        if (sysctl(mib, sizeof(mib)/sizeof(int), &num_cores,
> &num_cores_len, NULL, 0) == 0 && (num_cores > 0))
> > +        if (sysctl(mib, llvm::array_lengthof(mib), &num_cores,
> &num_cores_len, NULL, 0) == 0 && (num_cores > 0))
> >         {
> >             g_num_cores = num_cores;
> >         }
> > @@ -2071,7 +2072,7 @@ Host::GetNumberCPUS ()
> >         {
> >             mib[1] = HW_NCPU;
> >             num_cores_len = sizeof(num_cores);
> > -            if (sysctl(mib, sizeof(mib)/sizeof(int), &num_cores,
> &num_cores_len, NULL, 0) == 0 && (num_cores > 0))
> > +            if (sysctl(mib, llvm::array_lengthof(mib), &num_cores,
> &num_cores_len, NULL, 0) == 0 && (num_cores > 0))
> >             {
> >                 if (num_cores > 0)
> >                     g_num_cores = num_cores;
> >
> > Modified: lldb/trunk/source/Host/common/Terminal.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Terminal.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > --- lldb/trunk/source/Host/common/Terminal.cpp (original)
> > +++ lldb/trunk/source/Host/common/Terminal.cpp Fri Jun 27 00:17:41 2014
> > @@ -8,6 +8,7 @@
> >
> //===----------------------------------------------------------------------===//
> >
> > #include "lldb/Host/Terminal.h"
> > +#include "llvm/ADT/STLExtras.h"
> >
> > #include <fcntl.h>
> > #include <signal.h>
> > @@ -274,7 +275,7 @@ TerminalStateSwitcher::~TerminalStateSwi
> > uint32_t
> > TerminalStateSwitcher::GetNumberOfStates() const
> > {
> > -    return sizeof(m_ttystates)/sizeof(TerminalState);
> > +    return llvm::array_lengthof(m_ttystates);
> > }
> >
> > //------------------------------------------------------------------
> >
> > Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
> > +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Fri Jun 27
> 00:17:41 2014
> > @@ -67,6 +67,8 @@
> >
> > #include "lldb/Utility/CleanUp.h"
> >
> > +#include "llvm/ADT/STLExtras.h"
> > +
> > using namespace lldb;
> > using namespace lldb_private;
> >
> > @@ -417,7 +419,7 @@ CommandInterpreter::LoadCommandDictionar
> >
> {"^\\&(.*[^[:space:]])[[:space:]]*$", "breakpoint set --name '%1'
> --skip-prologue=0"},
> >                                       {"^(.*[^[:space:]])[[:space:]]*$",
> "breakpoint set --name '%1'"}};
> >
> > -    size_t num_regexes = sizeof break_regexes/sizeof(char *[2]);
> > +    size_t num_regexes = llvm::array_lengthof(break_regexes);
> >
> >     std::unique_ptr<CommandObjectRegexCommand>
> >     break_regex_cmd_ap(new CommandObjectRegexCommand (*this,
> >
> > Modified: lldb/trunk/source/Interpreter/OptionValueBoolean.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValueBoolean.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > --- lldb/trunk/source/Interpreter/OptionValueBoolean.cpp (original)
> > +++ lldb/trunk/source/Interpreter/OptionValueBoolean.cpp Fri Jun 27
> 00:17:41 2014
> > @@ -16,6 +16,7 @@
> > #include "lldb/Core/Stream.h"
> > #include "lldb/Core/StringList.h"
> > #include "lldb/Interpreter/Args.h"
> > +#include "llvm/ADT/STLExtras.h"
> >
> > using namespace lldb;
> > using namespace lldb_private;
> > @@ -110,7 +111,7 @@ OptionValueBoolean::AutoComplete (Comman
> >         { "1"    , 1 },
> >         { "0"    , 1 },
> >     };
> > -    const size_t k_num_autocomplete_entries =
> sizeof(g_autocomplete_entries)/sizeof(StringEntry);
> > +    const size_t k_num_autocomplete_entries =
> llvm::array_lengthof(g_autocomplete_entries);
> >
> >     if (s && s[0])
> >     {
> >
> > Modified: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > --- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp (original)
> > +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp Fri Jun
> 27 00:17:41 2014
> > @@ -24,6 +24,7 @@
> > #include "lldb/Target/Target.h"
> > #include "lldb/Target/Thread.h"
> >
> > +#include "llvm/ADT/STLExtras.h"
> > #include "llvm/ADT/Triple.h"
> >
> > #include "Utility/ARM_DWARF_Registers.h"
> > @@ -144,7 +145,7 @@ static RegisterInfo g_register_infos[] =
> >     {   "r13_svc", "sp_svc",  4, 0, eEncodingUint    , eFormatHex,   {
> LLDB_INVALID_REGNUM,  dwarf_r13_svc,      LLDB_INVALID_REGNUM,
>  LLDB_INVALID_REGNUM,    LLDB_INVALID_REGNUM },      NULL,
>  NULL},
> >     {   "r14_svc", "lr_svc",  4, 0, eEncodingUint    , eFormatHex,   {
> LLDB_INVALID_REGNUM,  dwarf_r14_svc,      LLDB_INVALID_REGNUM,
>  LLDB_INVALID_REGNUM,    LLDB_INVALID_REGNUM },      NULL,
>  NULL}
> > };
> > -static const uint32_t k_num_register_infos =
> sizeof(g_register_infos)/sizeof(RegisterInfo);
> > +static const uint32_t k_num_register_infos =
> llvm::array_lengthof(g_register_infos);
> > static bool g_register_info_names_constified = false;
> >
> > const lldb_private::RegisterInfo *
> > @@ -214,7 +215,7 @@ ABIMacOSX_arm::PrepareTrivialCall (Threa
> >
> >     llvm::ArrayRef<addr_t>::iterator ai = args.begin(), ae = args.end();
> >
> > -    for (size_t i = 0; i < (sizeof(reg_names) / sizeof(reg_names[0]));
> ++i)
> > +    for (size_t i = 0; i < llvm::array_lengthof(reg_names); ++i)
> >     {
> >         if (ai == ae)
> >             break;
> >
> > Modified: lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > --- lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
> (original)
> > +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp Fri
> Jun 27 00:17:41 2014
> > @@ -26,7 +26,7 @@
> > #include "lldb/Target/Target.h"
> > #include "lldb/Target/Thread.h"
> >
> > -
> > +#include "llvm/ADT/STLExtras.h"
> > #include "llvm/ADT/Triple.h"
> >
> > #include "Utility/ARM64_DWARF_Registers.h"
> > @@ -182,7 +182,7 @@ static RegisterInfo g_register_infos[] =
> >     {   "d31",     NULL,     8, 0, eEncodingIEEE754 , eFormatFloat
>   , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,    LLDB_INVALID_REGNUM,
>    LLDB_INVALID_REGNUM,    LLDB_INVALID_REGNUM }, NULL, NULL }
> > };
> >
> > -static const uint32_t k_num_register_infos =
> sizeof(g_register_infos)/sizeof(RegisterInfo);
> > +static const uint32_t k_num_register_infos =
> llvm::array_lengthof(g_register_infos);
> > static bool g_register_info_names_constified = false;
> >
> > const lldb_private::RegisterInfo *
> >
> > Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
> (original)
> > +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Fri Jun
> 27 00:17:41 2014
> > @@ -199,7 +199,7 @@ static RegisterInfo g_register_infos[] =
> >     { "ymm7"  , NULL,   32,  0, eEncodingVector, eFormatVectorOfUInt8, {
> LLDB_INVALID_REGNUM , dwarf_ymm7          , LLDB_INVALID_REGNUM       ,
> gdb_ymm7           , LLDB_INVALID_REGNUM },      NULL,              NULL}
> > };
> >
> > -static const uint32_t k_num_register_infos =
> sizeof(g_register_infos)/sizeof(RegisterInfo);
> > +static const uint32_t k_num_register_infos =
> llvm::array_lengthof(g_register_infos);
> > static bool g_register_info_names_constified = false;
> >
> > const lldb_private::RegisterInfo *
> >
> > Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > --- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
> (original)
> > +++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Fri Jun
> 27 00:17:41 2014
> > @@ -28,6 +28,7 @@
> > #include "lldb/Target/StackFrame.h"
> > #include "lldb/Target/Thread.h"
> >
> > +#include "llvm/ADT/STLExtras.h"
> > #include "llvm/ADT/Triple.h"
> >
> > using namespace lldb;
> > @@ -251,7 +252,7 @@ static RegisterInfo g_register_infos[] =
> >     { "ymm15" , NULL,   32,  0, eEncodingVector, eFormatVectorOfUInt8, {
> gcc_dwarf_ymm15     , gcc_dwarf_ymm15     , LLDB_INVALID_REGNUM       ,
> gdb_ymm15          , LLDB_INVALID_REGNUM },      NULL,              NULL}
> > };
> >
> > -static const uint32_t k_num_register_infos =
> sizeof(g_register_infos)/sizeof(RegisterInfo);
> > +static const uint32_t k_num_register_infos =
> llvm::array_lengthof(g_register_infos);
> > static bool g_register_info_names_constified = false;
> >
> > const lldb_private::RegisterInfo *
> >
> > Modified:
> lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
> (original)
> > +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
> Fri Jun 27 00:17:41 2014
> > @@ -24,6 +24,7 @@
> > #include "Plugins/Process/Utility/ARMUtils.h"
> > #include "Utility/ARM_DWARF_Registers.h"
> >
> > +#include "llvm/ADT/STLExtras.h"
> > #include "llvm/Support/MathExtras.h" // for SignExtend32 template
> function
> >                                      // and countTrailingZeros function
> >
> > @@ -12506,7 +12507,7 @@ EmulateInstructionARM::GetARMOpcodeForIn
> >         { 0xfe500000, 0xf8100000, ARMV6_ABOVE,  eEncodingA1, No_VFP,
> eSize32, &EmulateInstructionARM::EmulateRFE, "rfe{<amode>} <Rn>{!}" }
> >
> >     };
> > -    static const size_t k_num_arm_opcodes =
> sizeof(g_arm_opcodes)/sizeof(ARMOpcode);
> > +    static const size_t k_num_arm_opcodes =
> llvm::array_lengthof(g_arm_opcodes);
> >
> >     for (size_t i=0; i<k_num_arm_opcodes; ++i)
> >     {
> > @@ -12832,7 +12833,7 @@ EmulateInstructionARM::GetThumbOpcodeFor
> >         { 0xfffff080, 0xfa1ff080, ARMV6T2_ABOVE, eEncodingT2, No_VFP,
> eSize32, &EmulateInstructionARM::EmulateUXTH, "uxth<c>.w
> <Rd>,<Rm>{,<rotation>}" },
> >     };
> >
> > -    const size_t k_num_thumb_opcodes =
> sizeof(g_thumb_opcodes)/sizeof(ARMOpcode);
> > +    const size_t k_num_thumb_opcodes =
> llvm::array_lengthof(g_thumb_opcodes);
> >     for (size_t i=0; i<k_num_thumb_opcodes; ++i)
> >     {
> >         if ((g_thumb_opcodes[i].mask & opcode) ==
> g_thumb_opcodes[i].value &&
> >
> > Modified:
> lldb/trunk/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > ---
> lldb/trunk/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
> (original)
> > +++
> lldb/trunk/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp Fri
> Jun 27 00:17:41 2014
> > @@ -22,6 +22,7 @@
> > #include "Plugins/Process/Utility/ARMUtils.h"
> > #include "Utility/ARM64_DWARF_Registers.h"
> >
> > +#include "llvm/ADT/STLExtras.h"
> > #include "llvm/Support/MathExtras.h" // for SignExtend32 template
> function
> >                                      // and CountTrailingZeros_32
> function
> >
> > @@ -254,7 +255,7 @@ EmulateInstructionARM64::GetOpcodeForIns
> >         { 0xffc00000, 0xa9800000, No_VFP,
> &EmulateInstructionARM64::Emulate_ldstpair_pre, "STP  <Xt>, <Xt2>,
> [<Xn|SP>, #<imm>]!" },
> >
> >     };
> > -    static const size_t k_num_arm_opcodes =
> sizeof(g_opcodes)/sizeof(EmulateInstructionARM64::Opcode);
> > +    static const size_t k_num_arm_opcodes =
> llvm::array_lengthof(g_opcodes);
> >
> >     for (size_t i=0; i<k_num_arm_opcodes; ++i)
> >     {
> >
> > Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
> (original)
> > +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Fri Jun
> 27 00:17:41 2014
> > @@ -28,6 +28,7 @@
> > #include "lldb/Symbol/SymbolFile.h"
> > #include "lldb/Symbol/SymbolVendor.h"
> > #include "lldb/Target/Target.h"
> > +#include "llvm/ADT/STLExtras.h"
> >
> > using namespace lldb;
> > using namespace lldb_private;
> > @@ -1327,7 +1328,7 @@ PlatformDarwin::SetThreadCreationBreakpo
> >     };
> >
> >     FileSpecList bp_modules;
> > -    for (size_t i = 0; i < sizeof(g_bp_modules)/sizeof(const char *);
> i++)
> > +    for (size_t i = 0; i < llvm::array_lengthof(g_bp_modules); i++)
> >     {
> >         const char *bp_module = g_bp_modules[i];
> >         bp_modules.Append(FileSpec(bp_module, false));
> > @@ -1339,7 +1340,7 @@ PlatformDarwin::SetThreadCreationBreakpo
> >     bp_sp = target.CreateBreakpoint (&bp_modules,
> >                                      NULL,
> >                                      g_bp_names,
> > -                                     sizeof(g_bp_names)/sizeof(const
> char *),
> > +                                     llvm::array_lengthof(g_bp_names),
> >                                      eFunctionNameTypeFull,
> >                                      skip_prologue,
> >                                      internal,
> >
> > Modified:
> lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > ---
> lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
> (original)
> > +++
> lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp Fri
> Jun 27 00:17:41 2014
> > @@ -37,6 +37,8 @@
> > #include "ARM_GCC_Registers.h"
> > #include "ARM_DWARF_Registers.h"
> >
> > +#include "llvm/ADT/STLExtras.h"
> > +
> > using namespace lldb;
> > using namespace lldb_private;
> >
> > @@ -399,7 +401,7 @@ g_exc_regnums[] =
> >     exc_far,
> > };
> >
> > -static size_t k_num_register_infos =
> (sizeof(g_register_infos)/sizeof(RegisterInfo));
> > +static size_t k_num_register_infos =
> llvm::array_lengthof(g_register_infos);
> >
> > void
> > RegisterContextDarwin_arm::InvalidateAllRegisters ()
> > @@ -438,9 +440,9 @@ RegisterContextDarwin_arm::GetRegisterIn
> >
> >
> > // Number of registers in each register set
> > -const size_t k_num_gpr_registers = sizeof(g_gpr_regnums) /
> sizeof(uint32_t);
> > -const size_t k_num_fpu_registers = sizeof(g_fpu_regnums) /
> sizeof(uint32_t);
> > -const size_t k_num_exc_registers = sizeof(g_exc_regnums) /
> sizeof(uint32_t);
> > +const size_t k_num_gpr_registers = llvm::array_lengthof(g_gpr_regnums);
> > +const size_t k_num_fpu_registers = llvm::array_lengthof(g_fpu_regnums);
> > +const size_t k_num_exc_registers = llvm::array_lengthof(g_exc_regnums);
> >
> > //----------------------------------------------------------------------
> > // Register set definitions. The first definitions at register set index
> > @@ -454,7 +456,7 @@ static const RegisterSet g_reg_sets[] =
> >     { "Exception State Registers",  "exc",  k_num_exc_registers,
>  g_exc_regnums       }
> > };
> >
> > -const size_t k_num_regsets = sizeof(g_reg_sets) / sizeof(RegisterSet);
> > +const size_t k_num_regsets = llvm::array_lengthof(g_reg_sets);
> >
> >
> > size_t
> >
> > Modified:
> lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > ---
> lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
> (original)
> > +++
> lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
> Fri Jun 27 00:17:41 2014
> > @@ -24,6 +24,7 @@
> > #include "lldb/Core/RegisterValue.h"
> > #include "lldb/Core/Scalar.h"
> > #include "lldb/Host/Endian.h"
> > +#include "llvm/ADT/STLExtras.h"
> > #include "llvm/Support/Compiler.h"
> >
> > #include "Plugins/Process/Utility/InstructionUtils.h"
> > @@ -462,7 +463,7 @@ g_exc_regnums[] =
> >     exc_exception
> > };
> >
> > -static size_t k_num_register_infos =
> (sizeof(g_register_infos)/sizeof(RegisterInfo));
> > +static size_t k_num_register_infos =
> llvm::array_lengthof(g_register_infos);
> >
> > void
> > RegisterContextDarwin_arm64::InvalidateAllRegisters ()
> > @@ -501,9 +502,9 @@ RegisterContextDarwin_arm64::GetRegister
> >
> >
> > // Number of registers in each register set
> > -const size_t k_num_gpr_registers = sizeof(g_gpr_regnums) /
> sizeof(uint32_t);
> > -const size_t k_num_fpu_registers = sizeof(g_fpu_regnums) /
> sizeof(uint32_t);
> > -const size_t k_num_exc_registers = sizeof(g_exc_regnums) /
> sizeof(uint32_t);
> > +const size_t k_num_gpr_registers = llvm::array_lengthof(g_gpr_regnums);
> > +const size_t k_num_fpu_registers = llvm::array_lengthof(g_fpu_regnums);
> > +const size_t k_num_exc_registers = llvm::array_lengthof(g_exc_regnums);
> >
> > //----------------------------------------------------------------------
> > // Register set definitions. The first definitions at register set index
> > @@ -517,7 +518,7 @@ static const RegisterSet g_reg_sets[] =
> >     { "Exception State Registers",  "exc",  k_num_exc_registers,
>  g_exc_regnums       }
> > };
> >
> > -const size_t k_num_regsets = sizeof(g_reg_sets) / sizeof(RegisterSet);
> > +const size_t k_num_regsets = llvm::array_lengthof(g_reg_sets);
> >
> >
> > size_t
> >
> > Modified:
> lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > ---
> lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp
> (original)
> > +++
> lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp
> Fri Jun 27 00:17:41 2014
> > @@ -19,6 +19,7 @@
> > #include "lldb/Core/RegisterValue.h"
> > #include "lldb/Core/Scalar.h"
> > #include "lldb/Host/Endian.h"
> > +#include "llvm/ADT/STLExtras.h"
> > #include "llvm/Support/Compiler.h"
> >
> > // Support building against older versions of LLVM, this macro was added
> > @@ -281,7 +282,7 @@ static RegisterInfo g_register_infos[] =
> >     { DEFINE_EXC(faultvaddr)        , { LLDB_INVALID_REGNUM ,
> LLDB_INVALID_REGNUM   , LLDB_INVALID_REGNUM     , LLDB_INVALID_REGNUM,
> exc_faultvaddr },   NULL,              NULL}
> > };
> >
> > -static size_t k_num_register_infos =
> (sizeof(g_register_infos)/sizeof(RegisterInfo));
> > +static size_t k_num_register_infos =
> llvm::array_lengthof(g_register_infos);
> >
> > void
> > RegisterContextDarwin_i386::InvalidateAllRegisters ()
> > @@ -384,9 +385,9 @@ g_exc_regnums[] =
> > };
> >
> > // Number of registers in each register set
> > -const size_t k_num_gpr_registers = sizeof(g_gpr_regnums) /
> sizeof(uint32_t);
> > -const size_t k_num_fpu_registers = sizeof(g_fpu_regnums) /
> sizeof(uint32_t);
> > -const size_t k_num_exc_registers = sizeof(g_exc_regnums) /
> sizeof(uint32_t);
> > +const size_t k_num_gpr_registers = llvm::array_lengthof(g_gpr_regnums);
> > +const size_t k_num_fpu_registers = llvm::array_lengthof(g_fpu_regnums);
> > +const size_t k_num_exc_registers = llvm::array_lengthof(g_exc_regnums);
> >
> > //----------------------------------------------------------------------
> > // Register set definitions. The first definitions at register set index
> > @@ -400,7 +401,7 @@ static const RegisterSet g_reg_sets[] =
> >     { "Exception State Registers",  "exc",  k_num_exc_registers,
>  g_exc_regnums       }
> > };
> >
> > -const size_t k_num_regsets = sizeof(g_reg_sets) / sizeof(RegisterSet);
> > +const size_t k_num_regsets = llvm::array_lengthof(g_reg_sets);
> >
> >
> > size_t
> >
> > Modified:
> lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > ---
> lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
> (original)
> > +++
> lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
> Fri Jun 27 00:17:41 2014
> > @@ -21,6 +21,7 @@
> > #include "lldb/Core/RegisterValue.h"
> > #include "lldb/Core/Scalar.h"
> > #include "lldb/Host/Endian.h"
> > +#include "llvm/ADT/STLExtras.h"
> > #include "llvm/Support/Compiler.h"
> >
> > // Support building against older versions of LLVM, this macro was added
> > @@ -318,7 +319,7 @@ static RegisterInfo g_register_infos[] =
> >     { DEFINE_EXC(faultvaddr)        , { LLDB_INVALID_REGNUM,
> LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM      , LLDB_INVALID_REGNUM,
> exc_faultvaddr },      NULL,              NULL}
> > };
> >
> > -static size_t k_num_register_infos =
> (sizeof(g_register_infos)/sizeof(RegisterInfo));
> > +static size_t k_num_register_infos =
> llvm::array_lengthof(g_register_infos);
> >
> >
> > void
> > @@ -432,9 +433,9 @@ g_exc_regnums[] =
> > };
> >
> > // Number of registers in each register set
> > -const size_t k_num_gpr_registers = sizeof(g_gpr_regnums) /
> sizeof(uint32_t);
> > -const size_t k_num_fpu_registers = sizeof(g_fpu_regnums) /
> sizeof(uint32_t);
> > -const size_t k_num_exc_registers = sizeof(g_exc_regnums) /
> sizeof(uint32_t);
> > +const size_t k_num_gpr_registers = llvm::array_lengthof(g_gpr_regnums);
> > +const size_t k_num_fpu_registers = llvm::array_lengthof(g_fpu_regnums);
> > +const size_t k_num_exc_registers = llvm::array_lengthof(g_exc_regnums);
> >
> > //----------------------------------------------------------------------
> > // Register set definitions. The first definitions at register set index
> > @@ -448,7 +449,7 @@ static const RegisterSet g_reg_sets[] =
> >     { "Exception State Registers",  "exc",  k_num_exc_registers,
>  g_exc_regnums       }
> > };
> >
> > -const size_t k_num_regsets = sizeof(g_reg_sets) / sizeof(RegisterSet);
> > +const size_t k_num_regsets = llvm::array_lengthof(g_reg_sets);
> >
> >
> > size_t
> >
> > Modified:
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > ---
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
> (original)
> > +++
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
> Fri Jun 27 00:17:41 2014
> > @@ -17,6 +17,7 @@
> > #include <sstream>
> >
> > // Other libraries and framework includes
> > +#include "llvm/ADT/STLExtras.h"
> > #include "llvm/ADT/Triple.h"
> > #include "lldb/Interpreter/Args.h"
> > #include "lldb/Core/ConnectionFileDescriptor.h"
> > @@ -2660,8 +2661,8 @@ GDBRemoteCommunicationClient::TestPacket
> >     {
> >         static uint32_t g_send_sizes[] = { 0, 64, 128, 512, 1024 };
> >         static uint32_t g_recv_sizes[] = { 0, 64, 128, 512, 1024 }; //,
> 4*1024, 8*1024, 16*1024, 32*1024, 48*1024, 64*1024, 96*1024, 128*1024 };
> > -        const size_t k_num_send_sizes =
> sizeof(g_send_sizes)/sizeof(uint32_t);
> > -        const size_t k_num_recv_sizes =
> sizeof(g_recv_sizes)/sizeof(uint32_t);
> > +        const size_t k_num_send_sizes =
> llvm::array_lengthof(g_send_sizes);
> > +        const size_t k_num_recv_sizes =
> llvm::array_lengthof(g_recv_sizes);
> >         const uint64_t k_recv_amount = 4*1024*1024; // Receive 4MB
> >         for (uint32_t send_idx = 0; send_idx < k_num_send_sizes;
> ++send_idx)
> >         {
> >
> > Modified: lldb/trunk/source/Utility/SharingPtr.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/SharingPtr.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > --- lldb/trunk/source/Utility/SharingPtr.cpp (original)
> > +++ lldb/trunk/source/Utility/SharingPtr.cpp Fri Jun 27 00:17:41 2014
> > @@ -18,6 +18,8 @@
> > #include <assert.h>
> > #include "lldb/Host/Mutex.h"
> >
> > +#include "llvm/ADT/STLExtras.h"
> > +
> > #include <vector>
> >
> > class Backtrace
> > @@ -51,7 +53,7 @@ void
> > Backtrace::GetFrames ()
> > {
> >     void *frames[1024];
> > -    const int count = ::backtrace (frames,
> sizeof(frames)/sizeof(void*));
> > +    const int count = ::backtrace (frames,
> llvm::array_lengthof(frames));
> >     if (count > 2)
> >         m_frames.assign (frames + 2, frames + (count - 2));
> > }
> >
> > Modified: lldb/trunk/tools/debugserver/source/DNB.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNB.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > --- lldb/trunk/tools/debugserver/source/DNB.cpp (original)
> > +++ lldb/trunk/tools/debugserver/source/DNB.cpp Fri Jun 27 00:17:41 2014
> > @@ -47,6 +47,7 @@
> > #include "DNBTimer.h"
> > #include "CFBundle.h"
> >
> > +#include "llvm/ADT/STLExtras.h"
> >
> > typedef std::shared_ptr<MachProcess> MachProcessSP;
> > typedef std::map<nub_process_t, MachProcessSP> ProcessMap;
> > @@ -542,7 +543,7 @@ GetAllInfos (std::vector<struct kinfo_pr
> > {
> >     size_t size = 0;
> >     int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL };
> > -    u_int namelen = sizeof(name)/sizeof(int);
> > +    u_int namelen = llvm::array_lengthof(name);
> >     int err;
> >
> >     // Try to find out how many processes are around so we can
> >
> > Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > --- lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp
> (original)
> > +++ lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp Fri
> Jun 27 00:17:41 2014
> > @@ -20,6 +20,8 @@
> > #include "DNBThreadResumeActions.h"
> > #include "MachProcess.h"
> >
> > +#include "llvm/ADT/STLExtras.h"
> > +
> > MachThreadList::MachThreadList() :
> >     m_threads(),
> >     m_threads_mutex(PTHREAD_MUTEX_RECURSIVE),
> > @@ -313,7 +315,7 @@ MachThreadList::UpdateThreadList(MachPro
> >         int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID,
> process->ProcessID() };
> >         struct kinfo_proc processInfo;
> >         size_t bufsize = sizeof(processInfo);
> > -        if (sysctl(mib, (unsigned)(sizeof(mib)/sizeof(int)),
> &processInfo, &bufsize, NULL, 0) == 0 && bufsize > 0)
> > +        if (sysctl(mib, llvm::array_lengthof(mib), &processInfo,
> &bufsize, NULL, 0) == 0 && bufsize > 0)
> >         {
> >             if (processInfo.kp_proc.p_flag & P_LP64)
> >                 m_is_64_bit = true;
> >
> > 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=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > --- lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp
> (original)
> > +++ lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp Fri
> Jun 27 00:17:41 2014
> > @@ -23,6 +23,8 @@
> > #include "ARM_GCC_Registers.h"
> > #include "ARM_DWARF_Registers.h"
> >
> > +#include "llvm/ADT/STLExtras.h"
> > +
> > #include <inttypes.h>
> > #include <sys/sysctl.h>
> >
> > @@ -1555,9 +1557,9 @@ DNBArchMachARM::g_exc_registers[] =
> > };
> >
> > // Number of registers in each register set
> > -const size_t DNBArchMachARM::k_num_gpr_registers =
> sizeof(g_gpr_registers)/sizeof(DNBRegisterInfo);
> > -const size_t DNBArchMachARM::k_num_vfp_registers =
> sizeof(g_vfp_registers)/sizeof(DNBRegisterInfo);
> > -const size_t DNBArchMachARM::k_num_exc_registers =
> sizeof(g_exc_registers)/sizeof(DNBRegisterInfo);
> > +const size_t DNBArchMachARM::k_num_gpr_registers =
> llvm::array_lengthof(g_gpr_registers);
> > +const size_t DNBArchMachARM::k_num_vfp_registers =
> llvm::array_lengthof(g_vfp_registers);
> > +const size_t DNBArchMachARM::k_num_exc_registers =
> llvm::array_lengthof(g_exc_registers);
> > const size_t DNBArchMachARM::k_num_all_registers = k_num_gpr_registers +
> k_num_vfp_registers + k_num_exc_registers;
> >
> > //----------------------------------------------------------------------
> > @@ -1574,7 +1576,7 @@ DNBArchMachARM::g_reg_sets[] =
> >     { "Exception State Registers",  g_exc_registers,
>  k_num_exc_registers     }
> > };
> > // Total number of register sets for this architecture
> > -const size_t DNBArchMachARM::k_num_register_sets =
> sizeof(g_reg_sets)/sizeof(DNBRegisterSetInfo);
> > +const size_t DNBArchMachARM::k_num_register_sets =
> llvm::array_lengthof(g_reg_sets);
> >
> >
> > const DNBRegisterSetInfo *
> >
> > 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=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > ---
> lldb/trunk/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
> (original)
> > +++
> lldb/trunk/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp Fri
> Jun 27 00:17:41 2014
> > @@ -24,6 +24,8 @@
> > #include "DNBRegisterInfo.h"
> > #include "DNB.h"
> >
> > +#include "llvm/ADT/STLExtras.h"
> > +
> > #include <inttypes.h>
> > #include <sys/sysctl.h>
> >
> > @@ -1644,9 +1646,9 @@ DNBArchMachARM64::g_exc_registers[] =
> > };
> >
> > // Number of registers in each register set
> > -const size_t DNBArchMachARM64::k_num_gpr_registers =
> sizeof(g_gpr_registers)/sizeof(DNBRegisterInfo);
> > -const size_t DNBArchMachARM64::k_num_vfp_registers =
> sizeof(g_vfp_registers)/sizeof(DNBRegisterInfo);
> > -const size_t DNBArchMachARM64::k_num_exc_registers =
> sizeof(g_exc_registers)/sizeof(DNBRegisterInfo);
> > +const size_t DNBArchMachARM64::k_num_gpr_registers =
> llvm::array_lengthof(g_gpr_registers);
> > +const size_t DNBArchMachARM64::k_num_vfp_registers =
> llvm::array_lengthof(g_vfp_registers);
> > +const size_t DNBArchMachARM64::k_num_exc_registers =
> llvm::array_lengthof(g_exc_registers);
> > const size_t DNBArchMachARM64::k_num_all_registers = k_num_gpr_registers
> + k_num_vfp_registers + k_num_exc_registers;
> >
> > //----------------------------------------------------------------------
> > @@ -1663,7 +1665,7 @@ DNBArchMachARM64::g_reg_sets[] =
> >     { "Exception State Registers",  g_exc_registers,
>  k_num_exc_registers     }
> > };
> > // Total number of register sets for this architecture
> > -const size_t DNBArchMachARM64::k_num_register_sets =
> sizeof(g_reg_sets)/sizeof(DNBRegisterSetInfo);
> > +const size_t DNBArchMachARM64::k_num_register_sets =
> llvm::array_lengthof(g_reg_sets);
> >
> >
> > const DNBRegisterSetInfo *
> >
> > 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=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > --- lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp
> (original)
> > +++ lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp
> Fri Jun 27 00:17:41 2014
> > @@ -20,6 +20,8 @@
> > #include "MachThread.h"
> > #include "MachProcess.h"
> >
> > +#include "llvm/ADT/STLExtras.h"
> > +
> > extern "C" bool CPUHasAVX(); // Defined over in DNBArchImplX86_64.cpp
> >
> > #if defined (LLDB_DEBUGSERVER_RELEASE) || defined
> (LLDB_DEBUGSERVER_DEBUG)
> > @@ -1201,10 +1203,10 @@ DNBArchImplI386::g_exc_registers[] =
> > };
> >
> > // Number of registers in each register set
> > -const size_t DNBArchImplI386::k_num_gpr_registers =
> sizeof(g_gpr_registers)/sizeof(DNBRegisterInfo);
> > -const size_t DNBArchImplI386::k_num_fpu_registers_no_avx =
> sizeof(g_fpu_registers_no_avx)/sizeof(DNBRegisterInfo);
> > -const size_t DNBArchImplI386::k_num_fpu_registers_avx =
> sizeof(g_fpu_registers_avx)/sizeof(DNBRegisterInfo);
> > -const size_t DNBArchImplI386::k_num_exc_registers =
> sizeof(g_exc_registers)/sizeof(DNBRegisterInfo);
> > +const size_t DNBArchImplI386::k_num_gpr_registers =
> llvm::array_lengthof(g_gpr_registers);
> > +const size_t DNBArchImplI386::k_num_fpu_registers_no_avx =
> llvm::array_lengthof(g_fpu_registers_no_avx);
> > +const size_t DNBArchImplI386::k_num_fpu_registers_avx =
> llvm::array_lengthof(g_fpu_registers_avx);
> > +const size_t DNBArchImplI386::k_num_exc_registers =
> llvm::array_lengthof(g_exc_registers);
> > const size_t DNBArchImplI386::k_num_all_registers_no_avx =
> k_num_gpr_registers + k_num_fpu_registers_no_avx + k_num_exc_registers;
> > const size_t DNBArchImplI386::k_num_all_registers_avx =
> k_num_gpr_registers + k_num_fpu_registers_avx + k_num_exc_registers;
> >
> > @@ -1232,7 +1234,7 @@ DNBArchImplI386::g_reg_sets_avx[] =
> > };
> >
> > // Total number of register sets for this architecture
> > -const size_t DNBArchImplI386::k_num_register_sets =
> sizeof(g_reg_sets_no_avx)/sizeof(DNBRegisterSetInfo);
> > +const size_t DNBArchImplI386::k_num_register_sets =
> llvm::array_lengthof(g_reg_sets_no_avx);
> >
> > DNBArchProtocol *
> > DNBArchImplI386::Create (MachThread *thread)
> >
> > Modified: lldb/trunk/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > --- lldb/trunk/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp
> (original)
> > +++ lldb/trunk/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp Fri
> Jun 27 00:17:41 2014
> > @@ -25,6 +25,8 @@
> > #include "DNBLog.h"
> > #include "DNBRegisterInfo.h"
> >
> > +#include "llvm/ADT/STLExtras.h"
> > +
> > static const uint8_t g_breakpoint_opcode[] = { 0x7F, 0xC0, 0x00, 0x08 };
> >
> > const uint8_t * const
> > @@ -386,10 +388,10 @@ static DNBRegisterInfo g_vec_registers[]
> > };
> >
> > // Number of registers in each register set
> > -const size_t k_num_gpr_registers =
> sizeof(g_gpr_registers)/sizeof(DNBRegisterInfo);
> > -const size_t k_num_fpr_registers =
> sizeof(g_fpr_registers)/sizeof(DNBRegisterInfo);
> > -const size_t k_num_exc_registers =
> sizeof(g_exc_registers)/sizeof(DNBRegisterInfo);
> > -const size_t k_num_vec_registers =
> sizeof(g_vec_registers)/sizeof(DNBRegisterInfo);
> > +const size_t k_num_gpr_registers =
> llvm::array_lengthof(g_gpr_registers);
> > +const size_t k_num_fpr_registers =
> llvm::array_lengthof(g_fpr_registers);
> > +const size_t k_num_exc_registers =
> llvm::array_lengthof(g_exc_registers);
> > +const size_t k_num_vec_registers =
> llvm::array_lengthof(g_vec_registers);
> > // Total number of registers for this architecture
> > const size_t k_num_ppc_registers = k_num_gpr_registers +
> k_num_fpr_registers + k_num_exc_registers + k_num_vec_registers;
> >
> > @@ -407,7 +409,7 @@ static const DNBRegisterSetInfo g_reg_se
> >     { "Altivec Registers",            g_vec_registers,
> k_num_vec_registers }
> > };
> > // Total number of register sets for this architecture
> > -const size_t k_num_register_sets =
> sizeof(g_reg_sets)/sizeof(DNBRegisterSetInfo);
> > +const size_t k_num_register_sets = llvm::array_lengthof(g_reg_sets);
> >
> >
> > const DNBRegisterSetInfo *
> >
> > 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=211868&r1=211867&r2=211868&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 Fri
> Jun 27 00:17:41 2014
> > @@ -13,6 +13,8 @@
> >
> > #if defined (__i386__) || defined (__x86_64__)
> >
> > +#include "llvm/ADT/STLExtras.h"
> > +
> > #include <sys/cdefs.h>
> > #include <sys/types.h>
> > #include <sys/sysctl.h>
> > @@ -1525,10 +1527,10 @@ DNBArchImplX86_64::g_exc_registers[] =
> > };
> >
> > // Number of registers in each register set
> > -const size_t DNBArchImplX86_64::k_num_gpr_registers =
> sizeof(g_gpr_registers)/sizeof(DNBRegisterInfo);
> > -const size_t DNBArchImplX86_64::k_num_fpu_registers_no_avx =
> sizeof(g_fpu_registers_no_avx)/sizeof(DNBRegisterInfo);
> > -const size_t DNBArchImplX86_64::k_num_fpu_registers_avx =
> sizeof(g_fpu_registers_avx)/sizeof(DNBRegisterInfo);
> > -const size_t DNBArchImplX86_64::k_num_exc_registers =
> sizeof(g_exc_registers)/sizeof(DNBRegisterInfo);
> > +const size_t DNBArchImplX86_64::k_num_gpr_registers =
> llvm::array_lengthof(g_gpr_registers);
> > +const size_t DNBArchImplX86_64::k_num_fpu_registers_no_avx =
> llvm::array_lengthof(g_fpu_registers_no_avx);
> > +const size_t DNBArchImplX86_64::k_num_fpu_registers_avx =
> llvm::array_lengthof(g_fpu_registers_avx);
> > +const size_t DNBArchImplX86_64::k_num_exc_registers =
> llvm::array_lengthof(g_exc_registers);
> > const size_t DNBArchImplX86_64::k_num_all_registers_no_avx =
> k_num_gpr_registers + k_num_fpu_registers_no_avx + k_num_exc_registers;
> > const size_t DNBArchImplX86_64::k_num_all_registers_avx =
> k_num_gpr_registers + k_num_fpu_registers_avx + k_num_exc_registers;
> >
> > @@ -1556,7 +1558,7 @@ DNBArchImplX86_64::g_reg_sets_avx[] =
> > };
> >
> > // Total number of register sets for this architecture
> > -const size_t DNBArchImplX86_64::k_num_register_sets =
> sizeof(g_reg_sets_avx)/sizeof(DNBRegisterSetInfo);
> > +const size_t DNBArchImplX86_64::k_num_register_sets =
> llvm::array_lengthof(g_reg_sets_avx);
> >
> >
> > DNBArchProtocol *
> >
> > Modified: lldb/trunk/tools/debugserver/source/TTYState.h
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/TTYState.h?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > --- lldb/trunk/tools/debugserver/source/TTYState.h (original)
> > +++ lldb/trunk/tools/debugserver/source/TTYState.h Fri Jun 27 00:17:41
> 2014
> > @@ -17,6 +17,8 @@
> > #include <termios.h>
> > #include <stdint.h>
> >
> > +#include "llvm/ADT/STLExtras.h"
> > +
> > class TTYState
> > {
> > public:
> > @@ -50,7 +52,7 @@ public:
> >
> >     bool GetState(uint32_t idx, int fd, bool saveProcessGroup);
> >     bool SetState(uint32_t idx) const;
> > -    uint32_t NumStates() const { return
> sizeof(m_ttystates)/sizeof(TTYState); }
> > +    uint32_t NumStates() const { return
> llvm::array_lengthof(m_ttystates); }
> >     bool ValidStateIndex(uint32_t idx) const { return idx < NumStates();
> }
> >
> > protected:
> > @@ -58,4 +60,4 @@ protected:
> >     TTYState            m_ttystates[2];
> > };
> >
> > -#endif
> > \ No newline at end of file
> > +#endif
> >
> > Modified: lldb/trunk/tools/lldb-perf/common/clang/lldb_perf_clang.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-perf/common/clang/lldb_perf_clang.cpp?rev=211868&r1=211867&r2=211868&view=diff
> >
> ==============================================================================
> > --- lldb/trunk/tools/lldb-perf/common/clang/lldb_perf_clang.cpp
> (original)
> > +++ lldb/trunk/tools/lldb-perf/common/clang/lldb_perf_clang.cpp Fri Jun
> 27 00:17:41 2014
> > @@ -13,6 +13,7 @@
> > #include "lldb-perf/lib/Results.h"
> > #include "lldb-perf/lib/TestCase.h"
> > #include "lldb-perf/lib/Xcode.h"
> > +#include "llvm/ADT/STLExtras.h"
> > #include <iostream>
> > #include <unistd.h>
> > #include <fstream>
> > @@ -179,7 +180,7 @@ int main (int argc, char const *argv[],
> >                         "-x", "c++",
> >                         NULL,
> >                         NULL };
> > -                    clang_argv[sizeof(clang_argv)/sizeof(const char
> *)-2] = temp_source_path;
> > +                    clang_argv[llvm::array_lengthof(clang_argv)-2] =
> temp_source_path;
> >                     SBLaunchInfo launch_info(clang_argv);
> >                     Launch (launch_info);
> >                     next_action.None(); // Don't continue or do
> anything, just wait for next event...
> >
> >
> > _______________________________________________
> > lldb-commits mailing list
> > lldb-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
>
>


-- 
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20140627/dc90c03e/attachment.html>


More information about the lldb-commits mailing list