From df734cdd39cd3ad90f4f4466ddb497ffc14c1258 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Wed, 9 Jul 2014 16:32:07 +0000 Subject: [PATCH] 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 llvm-svn: 212628 --- lldb/source/Host/common/OptionParser.cpp | 17 ++++++++++++++++- lldb/source/Interpreter/OptionGroupBoolean.cpp | 1 + lldb/source/Interpreter/OptionGroupFile.cpp | 2 ++ lldb/source/Interpreter/OptionGroupString.cpp | 1 + lldb/source/Interpreter/OptionGroupUInt64.cpp | 1 + 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lldb/source/Host/common/OptionParser.cpp b/lldb/source/Host/common/OptionParser.cpp index 9a69e0e..a91e764 100644 --- a/lldb/source/Host/common/OptionParser.cpp +++ b/lldb/source/Host/common/OptionParser.cpp @@ -9,6 +9,9 @@ #include "lldb/Host/OptionParser.h" #include "lldb/Host/HostGetOpt.h" +#include "lldb/lldb-private-types.h" + +#include 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