20#include "llvm/Support/FormatAdapters.h"
35 value_sp = dynamic_sp;
41 value_sp = synthetic_sp;
50 return type_system.get()->GetBasicTypeFromAST(basic_type);
57 llvm::StringRef name) {
67llvm::Expected<lldb::ValueObjectSP>
70 return llvm::make_error<DILDiagnosticError>(
m_expr,
"invalid value object",
72 llvm::Expected<lldb::TypeSystemSP> type_system =
75 return type_system.takeError();
78 if (valobj->IsBitfield()) {
83 uint32_t bitfield_size = valobj->GetBitfieldBitSize();
86 if (bitfield_size > 0 && in_type.
IsInteger()) {
90 llvm::Expected<uint64_t> int_bit_size =
93 return int_bit_size.takeError();
94 llvm::Expected<uint64_t> uint_bit_size =
97 return int_bit_size.takeError();
98 if (bitfield_size < *int_bit_size ||
99 (in_type.
IsSigned() && bitfield_size == *int_bit_size))
100 return valobj->CastToBasicType(int_type);
101 if (bitfield_size <= *uint_bit_size)
102 return valobj->CastToBasicType(uint_type);
105 bool resolved = valobj->ResolveValue(scalar);
107 return llvm::createStringError(
"invalid scalar value");
116 if (valobj->GetCompilerType().IsInteger() ||
117 valobj->GetCompilerType().IsUnscopedEnumerationType()) {
118 llvm::Expected<CompilerType> promoted_type =
119 type_system.get()->DoIntegralPromotion(valobj->GetCompilerType(),
122 return promoted_type.takeError();
123 if (!promoted_type->CompareTypes(valobj->GetCompilerType()))
124 return valobj->CastToBasicType(*promoted_type);
170 switch (basic_type) {
189llvm::Expected<CompilerType>
194 llvm::Expected<uint64_t> lhs_size =
197 return lhs_size.takeError();
198 llvm::Expected<uint64_t> rhs_size =
201 return rhs_size.takeError();
203 if (*rhs_size == *lhs_size) {
204 llvm::Expected<lldb::TypeSystemSP> type_system =
207 return type_system.takeError();
212 return r_type_unsigned;
218llvm::Expected<CompilerType>
224 return lhs_or_err.takeError();
228 return rhs_or_err.takeError();
244 if (l_rank == 0 || r_rank == 0)
245 return llvm::make_error<DILDiagnosticError>(
246 m_expr,
"unexpected basic type in arithmetic operation", location);
251 using Rank = std::tuple<size_t, bool>;
252 Rank int_l_rank = {l_rank, !lhs_type.
IsSigned()};
253 Rank int_r_rank = {r_rank, !rhs_type.
IsSigned()};
254 if (int_l_rank < int_r_rank) {
257 return type_or_err.takeError();
260 if (int_l_rank > int_r_rank) {
263 return type_or_err.takeError();
278 std::vector<lldb::VariableSP> possible_matches;
281 llvm::StringRef str_ref_name = var_sp->GetName().GetStringRef();
283 str_ref_name.consume_front(
"::");
289 if (var_sp->NameMatches(name))
290 possible_matches.push_back(var_sp);
294 if (possible_matches.size() > 0)
295 return possible_matches[0];
301 llvm::StringRef name_ref, std::shared_ptr<StackFrame> stack_frame,
305 stack_frame->GetSymbolContext(lldb::eSymbolContextCompUnit);
310 name_ref.consume_front(
"::");
317 stack_frame->GetValueObjectForFrameVariable(var_sp, use_dynamic);
325 target_sp->GetImages().FindGlobalVariables(
326 ConstString(name_ref), std::numeric_limits<uint32_t>::max(),
329 if (!modules_var_list.
Empty()) {
342 std::shared_ptr<StackFrame> stack_frame,
346 if (name_ref.consume_front(
"$")) {
351 if (
const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(name_ref))
357 if (!name_ref.contains(
"::")) {
361 stack_frame->GetInScopeVariableList(
false));
366 variable_list->FindVariable(
ConstString(name_ref));
369 stack_frame->GetValueObjectForFrameVariable(var_sp, use_dynamic);
377 lldb::eSymbolContextFunction | lldb::eSymbolContextBlock);
379 value_sp = stack_frame->FindVariable(
ConstString(ivar_name));
381 value_sp = value_sp->GetChildMemberWithName(name_ref);
390 std::shared_ptr<StackFrame> frame_sp,
395 const bool check_ptr_vs_member =
397 const bool no_fragile_ivar =
399 const bool no_synth_child =
401 const bool allow_var_updates =
412 auto value_or_error = node.
Accept(
this);
414 if (value_or_error && !*value_or_error)
415 return llvm::make_error<DILDiagnosticError>(
m_expr,
"invalid value object",
419 return value_or_error;
422llvm::Expected<lldb::ValueObjectSP>
424 auto valobj_or_err =
Evaluate(node);
426 return valobj_or_err;
430 if (valobj->GetCompilerType().IsReferenceType()) {
431 valobj = valobj->Dereference(
error);
433 return error.ToError();
438llvm::Expected<lldb::ValueObjectSP>
450 llvm::formatv(
"use of undeclared identifier '{0}'", node.
GetName());
451 return llvm::make_error<DILDiagnosticError>(
458llvm::Expected<lldb::ValueObjectSP>
471 operand = dynamic_op;
477 child_sp = synth_obj_sp->Dereference(
error);
481 return llvm::make_error<DILDiagnosticError>(
m_expr,
error.AsCString(),
490 return llvm::make_error<DILDiagnosticError>(
m_expr,
error.AsCString(),
496 if (operand->GetCompilerType().IsReferenceType()) {
497 operand = operand->Dereference(
error);
499 return error.ToError();
501 llvm::Expected<lldb::ValueObjectSP> conv_op =
509 llvm::formatv(
"invalid argument type '{0}' to unary expression",
511 return llvm::make_error<DILDiagnosticError>(
m_expr, errMsg,
515 bool resolved = operand->ResolveValue(scalar);
526 if (operand->GetCompilerType().IsReferenceType()) {
527 operand = operand->Dereference(
error);
529 return error.ToError();
531 llvm::Expected<lldb::ValueObjectSP> conv_op =
541 llvm::formatv(
"invalid argument type '{0}' to unary expression",
543 return llvm::make_error<DILDiagnosticError>(
m_expr, errMsg,
549 return llvm::make_error<DILDiagnosticError>(
m_expr,
"invalid unary operation",
553llvm::Expected<lldb::ValueObjectSP>
557 if (ptr->GetCompilerType().IsPointerToVoid())
558 return llvm::make_error<DILDiagnosticError>(
559 m_expr,
"arithmetic on a pointer to void", location);
560 if (ptr->GetValueAsUnsigned(0) == 0 && offset != 0)
561 return llvm::make_error<DILDiagnosticError>(
562 m_expr,
"arithmetic on a nullptr is undefined", location);
565 int64_t offset_int = offset->GetValueAsSigned(0, &success);
567 std::string errMsg = llvm::formatv(
"could not get the offset: {0}",
568 offset->GetError().AsCString());
569 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(errMsg),
573 llvm::Expected<uint64_t> byte_size =
574 ptr->GetCompilerType().GetPointeeType().GetByteSize(
577 return byte_size.takeError();
578 uint64_t ptr_addr = ptr->GetValueAsUnsigned(0);
580 ptr_addr -= offset_int * (*byte_size);
582 ptr_addr += offset_int * (*byte_size);
590llvm::Expected<lldb::ValueObjectSP>
595 bool l_resolved = lhs->ResolveValue(
l);
596 bool r_resolved = rhs->ResolveValue(r);
598 if (!l_resolved || !r_resolved)
599 return llvm::make_error<DILDiagnosticError>(
m_expr,
"invalid scalar value",
602 auto value_object = [
this, result_type](
Scalar scalar) {
604 result_type,
"result");
609 return value_object(
l + r);
611 return value_object(
l - r);
613 return llvm::make_error<DILDiagnosticError>(
614 m_expr,
"invalid arithmetic operation", location);
623 auto orig_lhs_type = lhs->GetCompilerType();
624 auto orig_rhs_type = rhs->GetCompilerType();
627 return type_or_err.takeError();
636 if (lhs->GetCompilerType().IsPointerType()) {
639 }
else if (rhs->GetCompilerType().IsPointerType()) {
644 if (!ptr || !offset->GetCompilerType().IsInteger()) {
646 llvm::formatv(
"invalid operands to binary expression ('{0}' and '{1}')",
647 orig_lhs_type.GetTypeName(), orig_rhs_type.GetTypeName());
648 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(errMsg),
661 auto orig_lhs_type = lhs->GetCompilerType();
662 auto orig_rhs_type = rhs->GetCompilerType();
665 return type_or_err.takeError();
671 auto lhs_type = lhs->GetCompilerType();
672 auto rhs_type = rhs->GetCompilerType();
675 if (lhs_type.IsPointerType() && rhs_type.IsInteger())
679 if (lhs_type.IsPointerType() && rhs_type.IsPointerType()) {
680 if (lhs_type.IsPointerToVoid() && rhs_type.IsPointerToVoid()) {
681 return llvm::make_error<DILDiagnosticError>(
682 m_expr,
"arithmetic on pointers to void", location);
687 if (!lhs_unqualified_type.
CompareTypes(rhs_unqualified_type)) {
688 std::string errMsg = llvm::formatv(
689 "'{0}' and '{1}' are not pointers to compatible types",
690 orig_lhs_type.GetTypeName(), orig_rhs_type.GetTypeName());
691 return llvm::make_error<DILDiagnosticError>(
m_expr, errMsg, location);
694 llvm::Expected<uint64_t> lhs_byte_size =
697 return lhs_byte_size.takeError();
699 int64_t item_size = *lhs_byte_size;
700 int64_t diff =
static_cast<int64_t
>(lhs->GetValueAsUnsigned(0) -
701 rhs->GetValueAsUnsigned(0));
702 assert(item_size > 0 &&
"Pointee size cannot be 0");
703 if (diff % item_size != 0) {
706 return llvm::make_error<DILDiagnosticError>(
707 m_expr,
"undefined pointer arithmetic", location);
711 llvm::Expected<lldb::TypeSystemSP> type_system =
714 return type_system.takeError();
715 CompilerType ptrdiff_type = type_system.get()->GetPointerDiffType(
true);
717 return llvm::make_error<DILDiagnosticError>(
718 m_expr,
"unable to determine pointer diff type", location);
722 ptrdiff_type,
"result");
726 llvm::formatv(
"invalid operands to binary expression ('{0}' and '{1}')",
727 orig_lhs_type.GetTypeName(), orig_rhs_type.GetTypeName());
728 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(errMsg),
732llvm::Expected<lldb::ValueObjectSP>
744 lhs->GetCompilerType().GetTypeSystem().GetSharedPointer();
746 rhs->GetCompilerType().GetTypeSystem().GetSharedPointer();
747 if (lhs_system->GetPluginName() != rhs_system->GetPluginName()) {
749 return llvm::make_error<DILDiagnosticError>(
760 return llvm::make_error<DILDiagnosticError>(
764llvm::Expected<lldb::ValueObjectSP>
777 const uint32_t pointer_type_flags =
778 base->GetCompilerType().GetTypeInfo(
nullptr);
779 if ((pointer_type_flags & lldb::eTypeIsObjC) &&
780 (pointer_type_flags & lldb::eTypeIsPointer)) {
789 if (!base->IsPointerType() && base->HasSyntheticValue()) {
792 base->GetSyntheticValue()->Dereference(deref_error);
793 synth_deref_sp && deref_error.
Success()) {
794 base = std::move(synth_deref_sp);
796 if (!base || deref_error.
Fail()) {
797 std::string errMsg = llvm::formatv(
798 "Failed to dereference synthetic value: {0}", deref_error);
799 return llvm::make_error<DILDiagnosticError>(
805 std::string errMsg =
"Failed to dereference synthetic value";
806 return llvm::make_error<DILDiagnosticError>(
814 bool base_is_ptr = base->IsPointerType();
816 if (expr_is_ptr != base_is_ptr) {
819 llvm::formatv(
"member reference type {0} is a pointer; "
820 "did you mean to use '->'?",
821 base->GetCompilerType().TypeDescription());
822 return llvm::make_error<DILDiagnosticError>(
826 llvm::formatv(
"member reference type {0} is not a pointer; "
827 "did you mean to use '.'?",
828 base->GetCompilerType().TypeDescription());
829 return llvm::make_error<DILDiagnosticError>(
839 field_obj = base->GetSyntheticValue();
841 field_obj = field_obj->GetChildMemberWithName(node.
GetFieldName());
845 std::string errMsg = llvm::formatv(
846 "\"{0}\" is not a member of \"({1}) {2}\"", node.
GetFieldName(),
847 base->GetTypeName().AsCString(
"<invalid type>"), base->GetName());
848 return llvm::make_error<DILDiagnosticError>(
858 field_obj = dynamic_val_sp;
864 if (node.
GetIsArrow() && base->IsPointerType())
866 std::string errMsg = llvm::formatv(
867 "\"{0}\" is not a member of \"({1}) {2}\"", node.
GetFieldName(),
868 base->GetTypeName().AsCString(
"<invalid type>"), base->GetName());
869 return llvm::make_error<DILDiagnosticError>(
873llvm::Expected<lldb::ValueObjectSP>
880 if (!idx->GetCompilerType().IsIntegerOrUnscopedEnumerationType()) {
881 return llvm::make_error<DILDiagnosticError>(
886 uint64_t child_idx = idx->GetValueAsUnsigned(0);
894 CompilerType base_type = base->GetCompilerType().GetNonReferenceType();
895 base->GetExpressionPath(var_expr_path_strm);
896 bool is_incomplete_array =
false;
898 bool is_objc_pointer =
true;
901 is_objc_pointer =
false;
902 else if (!base->GetCompilerType().IsPointerType())
903 is_objc_pointer =
false;
906 std::string err_msg = llvm::formatv(
907 "\"({0}) {1}\" is an Objective-C pointer, and cannot be subscripted",
908 base->GetTypeName().AsCString(
"<invalid type>"),
910 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(err_msg),
913 if (is_objc_pointer) {
915 if (!synthetic || synthetic == base) {
916 std::string err_msg =
917 llvm::formatv(
"\"({0}) {1}\" is not an array type",
918 base->GetTypeName().AsCString(
"<invalid type>"),
920 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(err_msg),
923 if (
static_cast<uint32_t
>(child_idx) >=
924 synthetic->GetNumChildrenIgnoringErrors()) {
925 std::string err_msg = llvm::formatv(
926 "array index {0} is not valid for \"({1}) {2}\"", child_idx,
927 base->GetTypeName().AsCString(
"<invalid type>"),
929 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(err_msg),
932 child_valobj_sp = synthetic->GetChildAtIndex(child_idx);
933 if (!child_valobj_sp) {
934 std::string err_msg = llvm::formatv(
935 "array index {0} is not valid for \"({1}) {2}\"", child_idx,
936 base->GetTypeName().AsCString(
"<invalid type>"),
938 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(err_msg),
942 if (
auto dynamic_sp = child_valobj_sp->GetDynamicValue(
m_use_dynamic))
943 child_valobj_sp = std::move(dynamic_sp);
945 return child_valobj_sp;
948 child_valobj_sp = base->GetSyntheticArrayMember(child_idx,
true);
949 if (!child_valobj_sp) {
950 std::string err_msg = llvm::formatv(
951 "failed to use pointer as array for index {0} for "
953 child_idx, base->GetTypeName().AsCString(
"<invalid type>"),
956 err_msg =
"subscript of pointer to incomplete type 'void'";
957 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(err_msg),
960 }
else if (base_type.
IsArrayType(
nullptr,
nullptr, &is_incomplete_array)) {
961 child_valobj_sp = base->GetChildAtIndex(child_idx);
963 child_valobj_sp = base->GetSyntheticArrayMember(child_idx,
true);
964 if (!child_valobj_sp) {
965 std::string err_msg = llvm::formatv(
966 "array index {0} is not valid for \"({1}) {2}\"", child_idx,
967 base->GetTypeName().AsCString(
"<invalid type>"),
969 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(err_msg),
974 base->GetSyntheticBitFieldChild(child_idx, child_idx,
true);
975 if (!child_valobj_sp) {
976 std::string err_msg = llvm::formatv(
977 "bitfield range {0}:{1} is not valid for \"({2}) {3}\"", child_idx,
978 child_idx, base->GetTypeName().AsCString(
"<invalid type>"),
980 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(err_msg),
986 std::string err_msg =
987 llvm::formatv(
"\"{0}\" is not an array type",
988 base->GetTypeName().AsCString(
"<invalid type>"));
989 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(err_msg),
992 if (
static_cast<uint32_t
>(child_idx) >=
993 synthetic->GetNumChildrenIgnoringErrors(child_idx + 1)) {
994 std::string err_msg = llvm::formatv(
995 "array index {0} is not valid for \"({1}) {2}\"", child_idx,
996 base->GetTypeName().AsCString(
"<invalid type>"),
998 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(err_msg),
1001 child_valobj_sp = synthetic->GetChildAtIndex(child_idx);
1002 if (!child_valobj_sp) {
1003 std::string err_msg = llvm::formatv(
1004 "array index {0} is not valid for \"({1}) {2}\"", child_idx,
1005 base->GetTypeName().AsCString(
"<invalid type>"),
1006 var_expr_path_strm.
GetData());
1007 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(err_msg),
1012 if (child_valobj_sp) {
1014 if (
auto dynamic_sp = child_valobj_sp->GetDynamicValue(
m_use_dynamic))
1015 child_valobj_sp = std::move(dynamic_sp);
1017 return child_valobj_sp;
1021 int64_t signed_child_idx = idx->GetValueAsSigned(0, &success);
1023 return llvm::make_error<DILDiagnosticError>(
1024 m_expr,
"could not get the index as an integer",
1026 return base->GetSyntheticArrayMember(signed_child_idx,
true);
1029llvm::Expected<lldb::ValueObjectSP>
1032 if (!first_idx_or_err)
1033 return first_idx_or_err;
1036 if (!last_idx_or_err)
1037 return last_idx_or_err;
1040 if (!first_idx->GetCompilerType().IsIntegerOrUnscopedEnumerationType() ||
1041 !last_idx->GetCompilerType().IsIntegerOrUnscopedEnumerationType()) {
1042 return llvm::make_error<DILDiagnosticError>(
1046 bool success_first, success_last;
1047 int64_t first_index = first_idx->GetValueAsSigned(0, &success_first);
1048 int64_t last_index = last_idx->GetValueAsSigned(0, &success_last);
1049 if (!success_first || !success_last)
1050 return llvm::make_error<DILDiagnosticError>(
1054 if (first_index > last_index)
1055 std::swap(first_index, last_index);
1062 base->GetSyntheticBitFieldChild(first_index, last_index,
true);
1063 if (!child_valobj_sp) {
1064 std::string message = llvm::formatv(
1065 "bitfield range {0}:{1} is not valid for \"({2}) {3}\"", first_index,
1066 last_index, base->GetTypeName().AsCString(
"<invalid type>"),
1067 base->GetName().AsCString());
1068 return llvm::make_error<DILDiagnosticError>(
m_expr, message,
1071 return child_valobj_sp;
1074llvm::Expected<CompilerType>
1076 std::shared_ptr<ExecutionContextScope> ctx,
1081 llvm::APInt apint = literal.
GetValue();
1083 llvm::SmallVector<std::pair<lldb::BasicType, lldb::BasicType>, 3> candidates;
1094 for (
auto [signed_, unsigned_] : candidates) {
1095 CompilerType signed_type = type_system->GetBasicTypeFromAST(signed_);
1098 llvm::Expected<uint64_t> size = signed_type.
GetBitSize(ctx.get());
1100 return size.takeError();
1101 if (!literal.
IsUnsigned() && apint.isIntN(*size - 1))
1104 return type_system->GetBasicTypeFromAST(unsigned_);
1107 return llvm::make_error<DILDiagnosticError>(
1109 "integer literal is too large to be represented in any integer type",
1113llvm::Expected<lldb::ValueObjectSP>
1115 llvm::Expected<lldb::TypeSystemSP> type_system =
1118 return type_system.takeError();
1120 llvm::Expected<CompilerType> type =
1123 return type.takeError();
1128 llvm::Expected<uint64_t> type_bitsize =
1131 return type_bitsize.takeError();
1137llvm::Expected<lldb::ValueObjectSP>
1139 llvm::Expected<lldb::TypeSystemSP> type_system =
1142 return type_system.takeError();
1145 &node.
GetValue().getSemantics() == &llvm::APFloat::IEEEsingle();
1151 return llvm::make_error<DILDiagnosticError>(
1159llvm::Expected<lldb::ValueObjectSP>
1162 llvm::Expected<lldb::TypeSystemSP> type_system =
1165 return type_system.takeError();
1170llvm::Expected<CastKind>
1175 if (target_type.
GetTypeInfo() & lldb::eTypeIsFloat) {
1176 std::string errMsg = llvm::formatv(
"Cast from {0} to {1} is not allowed",
1179 return llvm::make_error<DILDiagnosticError>(
1180 m_expr, std::move(errMsg), location,
1190 uint64_t type_byte_size = 0;
1191 uint64_t rhs_type_byte_size = 0;
1193 type_byte_size = *temp;
1195 std::string errMsg = llvm::formatv(
"unable to get byte size for type {0}",
1197 return llvm::make_error<DILDiagnosticError>(
1198 m_expr, std::move(errMsg), location,
1203 rhs_type_byte_size = *temp;
1205 std::string errMsg = llvm::formatv(
"unable to get byte size for type {0}",
1207 return llvm::make_error<DILDiagnosticError>(
1208 m_expr, std::move(errMsg), location,
1212 if (type_byte_size < rhs_type_byte_size) {
1213 std::string errMsg = llvm::formatv(
1214 "cast from pointer to smaller type {0} loses information",
1216 return llvm::make_error<DILDiagnosticError>(
1217 m_expr, std::move(errMsg), location,
1222 std::string errMsg = llvm::formatv(
"cannot convert {0} to {1}",
1226 return llvm::make_error<DILDiagnosticError>(
1227 m_expr, std::move(errMsg), location,
1233llvm::Expected<CastKind>
1244 std::string errMsg = llvm::formatv(
"Cast from {0} to {1} is not allowed",
1248 return llvm::make_error<DILDiagnosticError>(
1249 m_expr, std::move(errMsg), location,
1259 std::string errMsg = llvm::formatv(
1260 "cannot cast from type {0} to pointer type {1}",
1263 return llvm::make_error<DILDiagnosticError>(
1264 m_expr, std::move(errMsg), location,
1271 std::string errMsg = llvm::formatv(
1272 "casting of {0} to {1} is not implemented yet",
1274 return llvm::make_error<DILDiagnosticError>(
1275 m_expr, std::move(errMsg), location,
1282 if (!operand_or_err)
1283 return operand_or_err;
1293 operand->GetName().GetStringRef());
1294 op_type = operand->GetCompilerType();
1299 return type_or_err.takeError();
1302 if (operand->GetCompilerType().IsReferenceType()) {
1304 operand = operand->Dereference(
error);
1306 return llvm::make_error<DILDiagnosticError>(
m_expr,
error.AsCString(),
1310 switch (cast_kind) {
1315 return operand->CastToEnumType(target_type);
1321 return operand->CastToBasicType(target_type);
1326 ? operand->GetLoadAddress()
1327 : (op_type.
IsSigned() ? operand->GetValueAsSigned(0)
1328 : operand->GetValueAsUnsigned(0));
1329 llvm::StringRef name =
"result";
1340 std::string errMsg =
1341 llvm::formatv(
"unable to cast from '{0}' to '{1}'",
1343 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(errMsg),
static llvm::raw_ostream & error(Stream &strm)
lldb::VariableListSP GetVariableList(bool can_create)
Get the variable list for a compile unit.
Generic representation of a type in a programming language.
bool IsEnumerationType(bool &is_signed) const
lldb::BasicType GetBasicTypeEnumeration() const
bool IsArrayType(CompilerType *element_type=nullptr, uint64_t *size=nullptr, bool *is_incomplete=nullptr) const
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
llvm::Expected< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
bool IsPointerToVoid() const
CompilerType GetNonReferenceType() const
If this type is a reference to a type (L value or R value reference), return a new type with the refe...
ConstString GetTypeName(bool BaseOnly=false) const
bool IsReferenceType(CompilerType *pointee_type=nullptr, bool *is_rvalue=nullptr) const
std::string TypeDescription()
CompilerType GetArrayElementType(ExecutionContextScope *exe_scope) const
Creating related types.
bool IsInteger() const
This is used when you don't care about the signedness of the integer.
CompilerType GetPointeeType() const
If this type is a pointer type, return the type that the pointer points to, else return an invalid ty...
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr) const
bool CompareTypes(CompilerType rhs) const
llvm::Expected< uint64_t > GetBitSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bits.
bool IsScalarType() const
bool IsNullPtrType() const
CompilerType GetCanonicalType() const
bool IsPointerType(CompilerType *pointee_type=nullptr) const
A uniqued constant string class.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
virtual void CalculateExecutionContext(ExecutionContext &exe_ctx)=0
Reconstruct the object's execution context into sc.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
void TruncOrExtendTo(uint16_t bits, bool sign)
Convert to an integer with bits and the given signedness.
@ eExpressionPathOptionsNoFragileObjcIvar
@ eExpressionPathOptionCheckPtrVsMember
@ eExpressionPathOptionsAllowVarUpdates
@ eExpressionPathOptionsNoSyntheticChildren
bool Fail() const
Test for error condition.
bool Success() const
Test for success condition.
const char * GetData() const
Defines a symbol context baton that can be handed other debug core functions.
llvm::StringRef GetInstanceVariableName()
Determines the name of the instance variable for the this decl context.
CompileUnit * comp_unit
The CompileUnit for a given query.
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, lldb::RegisterContextSP ®_ctx_sp, const RegisterInfo *reg_info)
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp)
static lldb::ValueObjectSP CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx, CompilerType type, bool do_deref=true)
Given an address either create a value object containing the value at that address,...
static lldb::ValueObjectSP CreateValueObjectFromScalar(const ExecutionContext &exe_ctx, Scalar &s, CompilerType type, llvm::StringRef name)
Create a value object containing the given Scalar value.
lldb::addr_t GetLoadAddress()
Return the target load address associated with this value object.
CompilerType GetCompilerType()
static lldb::ValueObjectSP CreateValueObjectFromBool(const ExecutionContext &exe_ctx, lldb::TypeSystemSP typesystem, bool value, llvm::StringRef name)
Create a value object containing the given boolean value.
The rest of the classes in this file, except for the Visitor class at the very end,...
uint32_t GetLocation() const
virtual llvm::Expected< lldb::ValueObjectSP > Accept(Visitor *v) const =0
ASTNode & GetBase() const
ASTNode & GetIndex() const
BinaryOpKind GetKind() const
ASTNode & GetOperand() const
CompilerType GetType() const
const llvm::APFloat & GetValue() const
std::string GetName() const
uint32_t GetRadix() const
IntegerTypeSuffix GetTypeSuffix() const
const llvm::APInt & GetValue() const
std::shared_ptr< StackFrame > m_exe_ctx_scope
llvm::Expected< lldb::ValueObjectSP > Evaluate(const ASTNode &node)
Evaluate an ASTNode.
llvm::Expected< lldb::ValueObjectSP > EvaluateBinaryAddition(lldb::ValueObjectSP lhs, lldb::ValueObjectSP rhs, uint32_t location)
llvm::Expected< lldb::ValueObjectSP > EvaluateAndDereference(const ASTNode &node)
Evaluate an ASTNode.
llvm::Expected< lldb::ValueObjectSP > PointerOffset(lldb::ValueObjectSP ptr, lldb::ValueObjectSP offset, BinaryOpKind operation, uint32_t location)
Add or subtract the offset to the pointer according to the pointee type byte size.
llvm::Expected< lldb::ValueObjectSP > EvaluateScalarOp(BinaryOpKind kind, lldb::ValueObjectSP lhs, lldb::ValueObjectSP rhs, CompilerType result_type, uint32_t location)
llvm::Expected< CompilerType > PromoteSignedInteger(CompilerType &lhs_type, CompilerType &rhs_type)
If lhs_type is unsigned and rhs_type is signed, check whether it can represent all of the values of l...
llvm::Expected< lldb::ValueObjectSP > EvaluateBinarySubtraction(lldb::ValueObjectSP lhs, lldb::ValueObjectSP rhs, uint32_t location)
llvm::Expected< lldb::ValueObjectSP > UnaryConversion(lldb::ValueObjectSP valobj, uint32_t location)
Perform usual unary conversions on a value.
llvm::Expected< lldb::ValueObjectSP > Visit(const IdentifierNode &node) override
bool m_check_ptr_vs_member
llvm::Expected< CompilerType > PickIntegerType(lldb::TypeSystemSP type_system, std::shared_ptr< ExecutionContextScope > ctx, const IntegerLiteralNode &literal)
Interpreter(lldb::TargetSP target, llvm::StringRef expr, std::shared_ptr< StackFrame > frame_sp, lldb::DynamicValueType use_dynamic, uint32_t options)
lldb::DynamicValueType m_use_dynamic
llvm::Expected< CompilerType > ArithmeticConversion(lldb::ValueObjectSP &lhs, lldb::ValueObjectSP &rhs, uint32_t location)
Perform an arithmetic conversion on two values from an arithmetic operation.
llvm::Expected< CastKind > VerifyCastType(lldb::ValueObjectSP operand, CompilerType source_type, CompilerType target_type, int location)
As a preparation for type casting, compare the requested 'target' type of the cast with the type of t...
llvm::Expected< CastKind > VerifyArithmeticCast(CompilerType source_type, CompilerType target_type, int location)
A helper function for VerifyCastType (below).
llvm::StringRef GetFieldName() const
ASTNode & GetBase() const
UnaryOpKind GetKind() const
ASTNode & GetOperand() const
CastKind
The type casts allowed by DIL.
@ eEnumeration
Casting from a scalar to an enumeration type.
@ ePointer
Casting to a pointer type.
@ eNone
Invalid promotion type (results in error).
@ eArithmetic
Casting to a scalar.
static lldb::BasicType BasicTypeToUnsigned(lldb::BasicType basic_type)
llvm::Expected< lldb::TypeSystemSP > GetTypeSystemFromCU(std::shared_ptr< StackFrame > ctx)
lldb::ValueObjectSP GetDynamicOrSyntheticValue(lldb::ValueObjectSP value_sp, lldb::DynamicValueType use_dynamic, bool use_synthetic)
static CompilerType GetBasicType(lldb::TypeSystemSP type_system, lldb::BasicType basic_type)
static lldb::ValueObjectSP ArrayToPointerConversion(ValueObject &valobj, ExecutionContextScope &ctx, llvm::StringRef name)
BinaryOpKind
The binary operators recognized by DIL.
static size_t ConversionRank(CompilerType type)
Basic types with a lower rank are converted to the basic type with a higher rank.
static lldb::VariableSP DILFindVariable(ConstString name, VariableList &variable_list)
lldb::ValueObjectSP LookupGlobalIdentifier(llvm::StringRef name_ref, std::shared_ptr< StackFrame > frame_sp, lldb::TargetSP target_sp, lldb::DynamicValueType use_dynamic)
Given the name of an identifier, check to see if it matches the name of a global variable.
lldb::ValueObjectSP LookupIdentifier(llvm::StringRef name_ref, std::shared_ptr< StackFrame > frame_sp, lldb::DynamicValueType use_dynamic)
Given the name of an identifier (variable name, member name, type name, etc.), find the ValueObject f...
std::shared_ptr< lldb_private::TypeSystem > TypeSystemSP
BasicType
Basic types enumeration for the public API SBType::GetBasicType().
@ eBasicTypeUnsignedShort
@ eBasicTypeUnsignedInt128
@ eBasicTypeUnsignedLongLong
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
@ eLanguageTypeObjC
Objective-C.
std::shared_ptr< lldb_private::VariableList > VariableListSP
std::shared_ptr< lldb_private::Variable > VariableSP
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
Every register is described in detail including its name, alternate name (optional),...