[lldb][dwarf] Compute fully qualified names on simplified template names with DWARFT...
[llvm-project.git] / lldb / source / Interpreter / OptionValueFormat.cpp
blobab89f673e96fe6779a1a43c15a66da682a0ff9e6
1 //===-- OptionValueFormat.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/OptionValueFormat.h"
11 #include "lldb/DataFormatters/FormatManager.h"
12 #include "lldb/Interpreter/OptionArgParser.h"
13 #include "lldb/Utility/Stream.h"
15 using namespace lldb;
16 using namespace lldb_private;
18 void OptionValueFormat::DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
19 uint32_t dump_mask) {
20 if (dump_mask & eDumpOptionType)
21 strm.Printf("(%s)", GetTypeAsCString());
22 if (dump_mask & eDumpOptionValue) {
23 if (dump_mask & eDumpOptionType)
24 strm.PutCString(" = ");
25 strm.PutCString(FormatManager::GetFormatAsCString(m_current_value));
29 llvm::json::Value OptionValueFormat::ToJSON(const ExecutionContext *exe_ctx) {
30 return FormatManager::GetFormatAsCString(m_current_value);
33 Status OptionValueFormat::SetValueFromString(llvm::StringRef value,
34 VarSetOperationType op) {
35 Status error;
36 switch (op) {
37 case eVarSetOperationClear:
38 Clear();
39 NotifyValueChanged();
40 break;
42 case eVarSetOperationReplace:
43 case eVarSetOperationAssign: {
44 Format new_format;
45 error = OptionArgParser::ToFormat(value.str().c_str(), new_format, nullptr);
46 if (error.Success()) {
47 m_value_was_set = true;
48 m_current_value = new_format;
49 NotifyValueChanged();
51 } break;
53 case eVarSetOperationInsertBefore:
54 case eVarSetOperationInsertAfter:
55 case eVarSetOperationRemove:
56 case eVarSetOperationAppend:
57 case eVarSetOperationInvalid:
58 error = OptionValue::SetValueFromString(value, op);
59 break;
61 return error;