Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / source / Interpreter / OptionValueUInt64.cpp
blob1999c63d11aff5a55cedf51afbb8567bf6db9de6
1 //===-- OptionValueUInt64.cpp ---------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "lldb/Interpreter/OptionValueUInt64.h"
11 #include "lldb/Utility/Stream.h"
13 using namespace lldb;
14 using namespace lldb_private;
16 lldb::OptionValueSP OptionValueUInt64::Create(llvm::StringRef value_str,
17 Status &error) {
18 lldb::OptionValueSP value_sp(new OptionValueUInt64());
19 error = value_sp->SetValueFromString(value_str);
20 if (error.Fail())
21 value_sp.reset();
22 return value_sp;
25 void OptionValueUInt64::DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
26 uint32_t dump_mask) {
27 if (dump_mask & eDumpOptionType)
28 strm.Printf("(%s)", GetTypeAsCString());
29 if (dump_mask & eDumpOptionValue) {
30 if (dump_mask & eDumpOptionType)
31 strm.PutCString(" = ");
32 strm.Printf("%" PRIu64, m_current_value);
36 Status OptionValueUInt64::SetValueFromString(llvm::StringRef value_ref,
37 VarSetOperationType op) {
38 Status error;
39 switch (op) {
40 case eVarSetOperationClear:
41 Clear();
42 NotifyValueChanged();
43 break;
45 case eVarSetOperationReplace:
46 case eVarSetOperationAssign: {
47 llvm::StringRef value_trimmed = value_ref.trim();
48 uint64_t value;
49 if (llvm::to_integer(value_trimmed, value)) {
50 m_value_was_set = true;
51 m_current_value = value;
52 NotifyValueChanged();
53 } else {
54 error.SetErrorStringWithFormat("invalid uint64_t string value: '%s'",
55 value_ref.str().c_str());
57 } break;
59 case eVarSetOperationInsertBefore:
60 case eVarSetOperationInsertAfter:
61 case eVarSetOperationRemove:
62 case eVarSetOperationAppend:
63 case eVarSetOperationInvalid:
64 error = OptionValue::SetValueFromString(value_ref, op);
65 break;
67 return error;