2011-05-04 06:09:39 +08:00
|
|
|
//===-- OptionGroupUUID.cpp -------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2011-05-04 06:09:39 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2011-05-14 04:21:08 +08:00
|
|
|
#include "lldb/Interpreter/OptionGroupUUID.h"
|
2011-05-04 06:09:39 +08:00
|
|
|
|
2017-03-23 07:33:16 +08:00
|
|
|
#include "lldb/Host/OptionParser.h"
|
2011-05-04 06:09:39 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
OptionGroupUUID::OptionGroupUUID() : m_uuid() {}
|
2011-05-04 06:09:39 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
OptionGroupUUID::~OptionGroupUUID() {}
|
2011-05-04 06:09:39 +08:00
|
|
|
|
2018-09-27 02:50:19 +08:00
|
|
|
static constexpr OptionDefinition g_option_table[] = {
|
2016-09-07 04:57:50 +08:00
|
|
|
{LLDB_OPT_SET_1, false, "uuid", 'u', OptionParser::eRequiredArgument,
|
2018-09-27 02:50:19 +08:00
|
|
|
nullptr, {}, 0, eArgTypeNone, "A module UUID value."},
|
2011-05-04 06:09:39 +08:00
|
|
|
};
|
|
|
|
|
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
|
|
|
llvm::ArrayRef<OptionDefinition> OptionGroupUUID::GetDefinitions() {
|
2016-09-23 05:06:13 +08:00
|
|
|
return llvm::makeArrayRef(g_option_table);
|
2011-05-04 06:09:39 +08:00
|
|
|
}
|
|
|
|
|
2017-05-12 12:51:55 +08:00
|
|
|
Status OptionGroupUUID::SetOptionValue(uint32_t option_idx,
|
|
|
|
llvm::StringRef option_arg,
|
|
|
|
ExecutionContext *execution_context) {
|
|
|
|
Status error;
|
2016-09-07 04:57:50 +08:00
|
|
|
const int short_option = g_option_table[option_idx].short_option;
|
|
|
|
|
|
|
|
switch (short_option) {
|
|
|
|
case 'u':
|
|
|
|
error = m_uuid.SetValueFromString(option_arg);
|
|
|
|
if (error.Success())
|
|
|
|
m_uuid.SetOptionWasSet();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
error.SetErrorStringWithFormat("unrecognized option '%c'", short_option);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
2011-05-04 06:09:39 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void OptionGroupUUID::OptionParsingStarting(
|
|
|
|
ExecutionContext *execution_context) {
|
|
|
|
m_uuid.Clear();
|
2011-05-04 06:09:39 +08:00
|
|
|
}
|