LLDB mainline
OptionValueLanguage.cpp
Go to the documentation of this file.
1//===-- OptionValueLanguage.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//===----------------------------------------------------------------------===//
8
10
14#include "lldb/Utility/Args.h"
15#include "lldb/Utility/Stream.h"
16
17using namespace lldb;
18using namespace lldb_private;
19
21 Stream &strm, uint32_t dump_mask) {
22 if (dump_mask & eDumpOptionType)
23 strm.Printf("(%s)", GetTypeAsCString());
24 if (dump_mask & eDumpOptionValue) {
25 if (dump_mask & eDumpOptionType)
26 strm.PutCString(" = ");
29 }
30}
31
32llvm::json::Value OptionValueLanguage::ToJSON(const ExecutionContext *exe_ctx) {
34}
35
39 switch (op) {
41 Clear();
42 break;
43
46 ConstString lang_name(value.trim());
48 LanguageType new_type =
50 if (new_type && languages_for_types[new_type]) {
51 m_value_was_set = true;
52 m_current_value = new_type;
53 } else {
54 StreamString error_strm;
55 error_strm.Printf("invalid language type '%s', ", value.str().c_str());
56 error_strm.Printf("valid values are:\n");
57 for (int bit : languages_for_types.bitvector.set_bits()) {
58 auto language = (LanguageType)bit;
59 error_strm.Printf(" %s\n",
61 }
62 error.SetErrorString(error_strm.GetString());
63 }
64 } break;
65
72 break;
73 }
74 return error;
75}
static llvm::raw_ostream & error(Stream &strm)
#define bit
A uniqued constant string class.
Definition: ConstString.h:39
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
Definition: ConstString.h:204
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
static LanguageSet GetLanguagesSupportingTypeSystems()
Definition: Language.cpp:389
static const char * GetNameForLanguageType(lldb::LanguageType language)
Definition: Language.cpp:232
static lldb::LanguageType GetLanguageTypeFromString(const char *string)=delete
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
virtual Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign)
virtual const char * GetTypeAsCString() const
Definition: OptionValue.h:82
An error handling class.
Definition: Status.h:44
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
VarSetOperationType
Settable state variable types.
Definition: SBAddress.h:15
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
Definition: TypeSystem.h:45
llvm::SmallBitVector bitvector
Definition: TypeSystem.h:46