summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2011-09-10 00:48:33 +0000
committerJohnny Chen <johnny.chen@apple.com>2011-09-10 00:48:33 +0000
commit7c575b3b3ae4aea7403f1bc78a6632cec58b8879 (patch)
tree262f8ed7da9e1710ab2dbdf60f01a6d00383d121 /lldb/source
parent964d758d17bad31b5b3b713827e613c444476d91 (diff)
downloadbcm5719-llvm-7c575b3b3ae4aea7403f1bc78a6632cec58b8879.tar.gz
bcm5719-llvm-7c575b3b3ae4aea7403f1bc78a6632cec58b8879.zip
Refactoring: replace a bunch of static array size computation or hardcoded constant
with a template function 'arraysize(static_array)', defined in Utils.h. llvm-svn: 139444
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/Interpreter/OptionGroupArchitecture.cpp7
-rw-r--r--lldb/source/Interpreter/OptionGroupFormat.cpp6
-rw-r--r--lldb/source/Interpreter/OptionGroupOutputFile.cpp9
-rw-r--r--lldb/source/Interpreter/OptionGroupPlatform.cpp7
-rw-r--r--lldb/source/Interpreter/OptionGroupUUID.cpp7
-rw-r--r--lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp5
-rw-r--r--lldb/source/Interpreter/OptionGroupWatchpoint.cpp5
7 files changed, 20 insertions, 26 deletions
diff --git a/lldb/source/Interpreter/OptionGroupArchitecture.cpp b/lldb/source/Interpreter/OptionGroupArchitecture.cpp
index 9446f2e73d5..377bac0c61a 100644
--- a/lldb/source/Interpreter/OptionGroupArchitecture.cpp
+++ b/lldb/source/Interpreter/OptionGroupArchitecture.cpp
@@ -13,6 +13,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Utility/Utils.h"
using namespace lldb;
using namespace lldb_private;
@@ -29,15 +30,13 @@ OptionGroupArchitecture::~OptionGroupArchitecture ()
static OptionDefinition
g_option_table[] =
{
-{ LLDB_OPT_SET_1 , false, "arch" , 'a', required_argument, NULL, 0, eArgTypeArchitecture , "Specify the architecture for the target."},
+ { LLDB_OPT_SET_1 , false, "arch" , 'a', required_argument, NULL, 0, eArgTypeArchitecture , "Specify the architecture for the target."},
};
-const uint32_t k_num_file_options = sizeof(g_option_table)/sizeof(OptionDefinition);
-
uint32_t
OptionGroupArchitecture::GetNumDefinitions ()
{
- return k_num_file_options;
+ return arraysize(g_option_table);
}
const OptionDefinition *
diff --git a/lldb/source/Interpreter/OptionGroupFormat.cpp b/lldb/source/Interpreter/OptionGroupFormat.cpp
index a42099db3c5..7f6ebbf51fd 100644
--- a/lldb/source/Interpreter/OptionGroupFormat.cpp
+++ b/lldb/source/Interpreter/OptionGroupFormat.cpp
@@ -13,6 +13,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Utility/Utils.h"
using namespace lldb;
using namespace lldb_private;
@@ -35,14 +36,13 @@ OptionGroupFormat::~OptionGroupFormat ()
static OptionDefinition
g_option_table[] =
{
-{ LLDB_OPT_SET_1 , false, "format", 'f', required_argument, NULL, 0, eArgTypeFormat , "Specify a format to be used for display."},
+ { LLDB_OPT_SET_1 , false, "format", 'f', required_argument, NULL, 0, eArgTypeFormat , "Specify a format to be used for display."},
};
-const uint32_t k_num_file_options = sizeof(g_option_table)/sizeof(OptionDefinition);
uint32_t
OptionGroupFormat::GetNumDefinitions ()
{
- return k_num_file_options;
+ return arraysize(g_option_table);
}
const OptionDefinition *
diff --git a/lldb/source/Interpreter/OptionGroupOutputFile.cpp b/lldb/source/Interpreter/OptionGroupOutputFile.cpp
index 541c8b4e8e7..f5daa3a5b72 100644
--- a/lldb/source/Interpreter/OptionGroupOutputFile.cpp
+++ b/lldb/source/Interpreter/OptionGroupOutputFile.cpp
@@ -13,6 +13,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Utility/Utils.h"
using namespace lldb;
using namespace lldb_private;
@@ -30,16 +31,14 @@ OptionGroupOutputFile::~OptionGroupOutputFile ()
static OptionDefinition
g_option_table[] =
{
-{ LLDB_OPT_SET_1 , false, "outfile", 'o', required_argument, NULL, 0, eArgTypePath , "Specify a path for capturing command output."},
-{ LLDB_OPT_SET_1 , false, "append-outfile" , 'A', no_argument, NULL, 0, eArgTypeNone , "Append to the the file specified with '--outfile <path>'."},
+ { LLDB_OPT_SET_1 , false, "outfile", 'o', required_argument, NULL, 0, eArgTypePath , "Specify a path for capturing command output."},
+ { LLDB_OPT_SET_1 , false, "append-outfile" , 'A', no_argument, NULL, 0, eArgTypeNone , "Append to the the file specified with '--outfile <path>'."},
};
-const uint32_t k_num_file_options = sizeof(g_option_table)/sizeof(OptionDefinition);
-
uint32_t
OptionGroupOutputFile::GetNumDefinitions ()
{
- return k_num_file_options;
+ return arraysize(g_option_table);
}
const OptionDefinition *
diff --git a/lldb/source/Interpreter/OptionGroupPlatform.cpp b/lldb/source/Interpreter/OptionGroupPlatform.cpp
index 1734a792d60..910a6e9b376 100644
--- a/lldb/source/Interpreter/OptionGroupPlatform.cpp
+++ b/lldb/source/Interpreter/OptionGroupPlatform.cpp
@@ -15,6 +15,7 @@
// Project includes
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Target/Platform.h"
+#include "lldb/Utility/Utils.h"
using namespace lldb;
using namespace lldb_private;
@@ -67,8 +68,6 @@ g_option_table[] =
{ LLDB_OPT_SET_ALL, false, "sysroot" , 's', required_argument, NULL, 0, eArgTypeFilename, "Specify the SDK root directory that contains a root of all remote system files." }
};
-static const uint32_t k_option_table_size = sizeof(g_option_table)/sizeof (OptionDefinition);
-
const OptionDefinition*
OptionGroupPlatform::GetDefinitions ()
{
@@ -81,8 +80,8 @@ uint32_t
OptionGroupPlatform::GetNumDefinitions ()
{
if (m_include_platform_option)
- return k_option_table_size;
- return k_option_table_size - 1;
+ return arraysize(g_option_table);
+ return arraysize(g_option_table) - 1;
}
diff --git a/lldb/source/Interpreter/OptionGroupUUID.cpp b/lldb/source/Interpreter/OptionGroupUUID.cpp
index b1b3c77ee2d..d009008b51f 100644
--- a/lldb/source/Interpreter/OptionGroupUUID.cpp
+++ b/lldb/source/Interpreter/OptionGroupUUID.cpp
@@ -13,6 +13,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Utility/Utils.h"
using namespace lldb;
using namespace lldb_private;
@@ -29,15 +30,13 @@ OptionGroupUUID::~OptionGroupUUID ()
static OptionDefinition
g_option_table[] =
{
-{ LLDB_OPT_SET_1 , false, "uuid", 'u', required_argument, NULL, 0, eArgTypeNone, "A module UUID value."},
+ { LLDB_OPT_SET_1 , false, "uuid", 'u', required_argument, NULL, 0, eArgTypeNone, "A module UUID value."},
};
-const uint32_t k_num_file_options = sizeof(g_option_table)/sizeof(OptionDefinition);
-
uint32_t
OptionGroupUUID::GetNumDefinitions ()
{
- return k_num_file_options;
+ return arraysize(g_option_table);
}
const OptionDefinition *
diff --git a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
index 5f540d60d06..4557883ecc0 100644
--- a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
+++ b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
@@ -15,6 +15,7 @@
// Project includes
#include "lldb/Target/Target.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Utility/Utils.h"
using namespace lldb;
using namespace lldb_private;
@@ -45,12 +46,10 @@ g_option_table[] =
{ 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL }
};
-const uint32_t k_num_file_options = sizeof(g_option_table)/sizeof(OptionDefinition);
-
uint32_t
OptionGroupValueObjectDisplay::GetNumDefinitions ()
{
- return k_num_file_options;
+ return arraysize(g_option_table);
}
const OptionDefinition *
diff --git a/lldb/source/Interpreter/OptionGroupWatchpoint.cpp b/lldb/source/Interpreter/OptionGroupWatchpoint.cpp
index 6d1fcb75e5b..be1bf57f51a 100644
--- a/lldb/source/Interpreter/OptionGroupWatchpoint.cpp
+++ b/lldb/source/Interpreter/OptionGroupWatchpoint.cpp
@@ -15,6 +15,7 @@
// Project includes
#include "lldb/lldb-enumerations.h"
#include "lldb/Interpreter/Args.h"
+#include "lldb/Utility/Utils.h"
using namespace lldb;
using namespace lldb_private;
@@ -84,7 +85,5 @@ OptionGroupWatchpoint::GetDefinitions ()
uint32_t
OptionGroupWatchpoint::GetNumDefinitions ()
{
- return 1;
+ return arraysize(g_option_table);
}
-
-
OpenPOWER on IntegriCloud