[lldb][dwarf] Compute fully qualified names on simplified template names with DWARFT...
[llvm-project.git] / lldb / source / Interpreter / OptionValueChar.cpp
blob2aadcff1583889f2e3b88d37264515be49725439
1 //===-- OptionValueChar.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/OptionValueChar.h"
11 #include "lldb/Interpreter/OptionArgParser.h"
12 #include "lldb/Utility/Stream.h"
13 #include "lldb/Utility/StringList.h"
14 #include "llvm/ADT/STLExtras.h"
16 using namespace lldb;
17 using namespace lldb_private;
19 void OptionValueChar::DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
20 uint32_t dump_mask) {
21 if (dump_mask & eDumpOptionType)
22 strm.Printf("(%s)", GetTypeAsCString());
24 if (dump_mask & eDumpOptionValue) {
25 if (dump_mask & eDumpOptionType)
26 strm.PutCString(" = ");
27 if (m_current_value != '\0')
28 strm.PutChar(m_current_value);
29 else
30 strm.PutCString("(null)");
34 Status OptionValueChar::SetValueFromString(llvm::StringRef value,
35 VarSetOperationType op) {
36 Status error;
37 switch (op) {
38 case eVarSetOperationClear:
39 Clear();
40 break;
42 case eVarSetOperationReplace:
43 case eVarSetOperationAssign: {
44 bool success = false;
45 char char_value = OptionArgParser::ToChar(value, '\0', &success);
46 if (success) {
47 m_current_value = char_value;
48 m_value_was_set = true;
49 } else
50 return Status::FromErrorStringWithFormatv(
51 "'{0}' cannot be longer than 1 character", value);
52 } break;
54 default:
55 error = OptionValue::SetValueFromString(value, op);
56 break;
58 return error;