[Lldb-commits] [lldb] r212628 - Fix tests broken by the OptionValidator changes.
Zachary Turner
zturner at google.com
Wed Jul 9 09:32:07 PDT 2014
Author: zturner
Date: Wed Jul 9 11:32:07 2014
New Revision: 212628
URL: http://llvm.org/viewvc/llvm-project?rev=212628&view=rev
Log:
Fix tests broken by the OptionValidator changes.
The getopt library has a structure called option (lowercase). We
have a structure called Option (uppercase). previously the two
structures had exactly the same definitions, and we were doing a
C-style cast of an Option* to an option*. C-style casts don't
bother to warn you when you cast to unrelated types, but in the
original OptionValidator patch I modified the definition of Option.
This patch fixes the errors by building an array of option
structures and filling it out the correct way before passing it to
the getopt library.
This also fixes one other source of test failures: an uninitialized
read that occurs due to not initializing a field of the
OptionDefinition.
Reviewed By: Todd Fiala
Differential Revision: http://reviews.llvm.org/D4425
Modified:
lldb/trunk/source/Host/common/OptionParser.cpp
lldb/trunk/source/Interpreter/OptionGroupBoolean.cpp
lldb/trunk/source/Interpreter/OptionGroupFile.cpp
lldb/trunk/source/Interpreter/OptionGroupString.cpp
lldb/trunk/source/Interpreter/OptionGroupUInt64.cpp
Modified: lldb/trunk/source/Host/common/OptionParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/OptionParser.cpp?rev=212628&r1=212627&r2=212628&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/OptionParser.cpp (original)
+++ lldb/trunk/source/Host/common/OptionParser.cpp Wed Jul 9 11:32:07 2014
@@ -9,6 +9,9 @@
#include "lldb/Host/OptionParser.h"
#include "lldb/Host/HostGetOpt.h"
+#include "lldb/lldb-private-types.h"
+
+#include <vector>
using namespace lldb_private;
@@ -36,7 +39,19 @@ OptionParser::Parse (int argc,
const Option *longopts,
int *longindex)
{
- return getopt_long_only(argc, argv, optstring, (const option*)longopts, longindex);
+ std::vector<option> opts;
+ while (longopts->definition != nullptr)
+ {
+ option opt;
+ opt.flag = longopts->flag;
+ opt.val = longopts->val;
+ opt.name = longopts->definition->long_option;
+ opt.has_arg = longopts->definition->option_has_arg;
+ opts.push_back(opt);
+ ++longopts;
+ }
+ opts.push_back(option());
+ return getopt_long_only(argc, argv, optstring, &opts[0], longindex);
}
char*
Modified: lldb/trunk/source/Interpreter/OptionGroupBoolean.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupBoolean.cpp?rev=212628&r1=212627&r2=212628&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionGroupBoolean.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionGroupBoolean.cpp Wed Jul 9 11:32:07 2014
@@ -30,6 +30,7 @@ OptionGroupBoolean::OptionGroupBoolean (
m_option_definition.required = required;
m_option_definition.long_option = long_option;
m_option_definition.short_option = short_option;
+ m_option_definition.validator = nullptr;
m_option_definition.option_has_arg = no_argument_toggle_default ? OptionParser::eNoArgument : OptionParser::eRequiredArgument;
m_option_definition.enum_values = nullptr;
m_option_definition.completion_type = 0;
Modified: lldb/trunk/source/Interpreter/OptionGroupFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupFile.cpp?rev=212628&r1=212627&r2=212628&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionGroupFile.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionGroupFile.cpp Wed Jul 9 11:32:07 2014
@@ -30,6 +30,7 @@ OptionGroupFile::OptionGroupFile (uint32
m_option_definition.required = required;
m_option_definition.long_option = long_option;
m_option_definition.short_option = short_option;
+ m_option_definition.validator = nullptr;
m_option_definition.option_has_arg = OptionParser::eRequiredArgument;
m_option_definition.enum_values = nullptr;
m_option_definition.completion_type = completion_type;
@@ -70,6 +71,7 @@ OptionGroupFileList::OptionGroupFileList
m_option_definition.required = required;
m_option_definition.long_option = long_option;
m_option_definition.short_option = short_option;
+ m_option_definition.validator = nullptr;
m_option_definition.option_has_arg = OptionParser::eRequiredArgument;
m_option_definition.enum_values = nullptr;
m_option_definition.completion_type = completion_type;
Modified: lldb/trunk/source/Interpreter/OptionGroupString.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupString.cpp?rev=212628&r1=212627&r2=212628&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionGroupString.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionGroupString.cpp Wed Jul 9 11:32:07 2014
@@ -31,6 +31,7 @@ OptionGroupString::OptionGroupString (ui
m_option_definition.required = required;
m_option_definition.long_option = long_option;
m_option_definition.short_option = short_option;
+ m_option_definition.validator = nullptr;
m_option_definition.option_has_arg = OptionParser::eRequiredArgument;
m_option_definition.enum_values = nullptr;
m_option_definition.completion_type = completion_type;
Modified: lldb/trunk/source/Interpreter/OptionGroupUInt64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupUInt64.cpp?rev=212628&r1=212627&r2=212628&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionGroupUInt64.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionGroupUInt64.cpp Wed Jul 9 11:32:07 2014
@@ -31,6 +31,7 @@ OptionGroupUInt64::OptionGroupUInt64 (ui
m_option_definition.required = required;
m_option_definition.long_option = long_option;
m_option_definition.short_option = short_option;
+ m_option_definition.validator = nullptr;
m_option_definition.option_has_arg = OptionParser::eRequiredArgument;
m_option_definition.enum_values = nullptr;
m_option_definition.completion_type = completion_type;
More information about the lldb-commits
mailing list