23#include "llvm/Support/ErrorExtras.h"
24#include "llvm/Support/FormatAdapters.h"
32 return type_system.get()->GetBasicTypeFromAST(basic_type);
39 llvm::StringRef name) {
49static llvm::Expected<lldb::LanguageType>
54 return llvm::createStringErrorV(
"no compile unit for frame: {}",
64 return llvm::createStringErrorV(
"no compile unit for frame: {}",
69 return symbol_context.
module_sp->GetTypeSystemForLanguage(language);
72llvm::Expected<lldb::ValueObjectSP>
75 return llvm::make_error<DILDiagnosticError>(
m_expr,
"invalid value object",
77 llvm::Expected<lldb::TypeSystemSP> type_system =
80 return type_system.takeError();
83 if (valobj->IsBitfield()) {
88 uint32_t bitfield_size = valobj->GetBitfieldBitSize();
91 if (bitfield_size > 0 && in_type.
IsInteger()) {
95 llvm::Expected<uint64_t> int_bit_size =
98 return int_bit_size.takeError();
99 llvm::Expected<uint64_t> uint_bit_size =
102 return uint_bit_size.takeError();
103 if (bitfield_size < *int_bit_size ||
104 (in_type.
IsSigned() && bitfield_size == *int_bit_size)) {
105 auto result = valobj->CastToBasicType(int_type);
106 if (result->GetError().Fail())
107 return llvm::make_error<DILDiagnosticError>(
108 m_expr, result->GetError().AsCString(), location);
111 if (bitfield_size <= *uint_bit_size) {
112 auto result = valobj->CastToBasicType(uint_type);
113 if (result->GetError().Fail())
114 return llvm::make_error<DILDiagnosticError>(
115 m_expr, result->GetError().AsCString(), location);
120 bool resolved = valobj->ResolveValue(scalar);
122 return llvm::createStringError(
"invalid scalar value");
132 valobj->GetCompilerType().GetPromotedIntegerType();
134 auto result = valobj->CastToBasicType(promoted_type);
135 if (result->GetError().Fail())
136 return llvm::make_error<DILDiagnosticError>(
137 m_expr, result->GetError().AsCString(), location);
184 switch (basic_type) {
203llvm::Expected<CompilerType>
210 return lhs_size.takeError();
213 return rhs_size.takeError();
215 if (*rhs_size == *lhs_size) {
216 llvm::Expected<lldb::TypeSystemSP> type_system =
219 return type_system.takeError();
224 return r_type_unsigned;
230llvm::Expected<CompilerType>
236 return lhs_or_err.takeError();
240 return rhs_or_err.takeError();
256 if (l_rank == 0 || r_rank == 0)
257 return llvm::make_error<DILDiagnosticError>(
258 m_expr,
"unexpected basic type in arithmetic operation", location);
263 using Rank = std::tuple<size_t, bool>;
264 Rank int_l_rank = {l_rank, !lhs_type.
IsSigned()};
265 Rank int_r_rank = {r_rank, !rhs_type.
IsSigned()};
266 if (int_l_rank < int_r_rank) {
269 return type_or_err.takeError();
272 if (int_l_rank > int_r_rank) {
275 return type_or_err.takeError();
290 std::vector<lldb::VariableSP> possible_matches;
293 llvm::StringRef str_ref_name = var_sp->GetName().GetStringRef();
295 str_ref_name.consume_front(
"::");
301 if (var_sp->NameMatches(name))
302 possible_matches.push_back(var_sp);
306 if (possible_matches.size() > 0)
307 return possible_matches[0];
323 name_ref.consume_front(
"::");
338 target_sp->GetImages().FindGlobalVariables(
339 ConstString(name_ref), std::numeric_limits<uint32_t>::max(),
342 if (!modules_var_list.
Empty()) {
358 if (name_ref.starts_with(
"$")) {
360 target_sp->GetPersistentExpressionStateForLanguage(language))
361 if (
auto var_sp = state->GetVariable(name_ref))
362 if (
auto valobj_sp = var_sp->GetValueObject())
373 if (name_ref.consume_front(
"$")) {
378 if (
const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(name_ref))
384 if (!name_ref.contains(
"::")) {
393 variable_list->FindVariable(
ConstString(name_ref));
404 lldb::eSymbolContextFunction | lldb::eSymbolContextBlock);
408 value_sp = value_sp->GetChildMemberWithName(name_ref);
418 if (name_ref.contains(
"::")) {
419 llvm::StringRef enum_typename, enumerator_name;
422 std::tie(enum_typename, enumerator_name) = name_ref.rsplit(
"::");
427 const llvm::APSInt &value) ->
bool {
428 if (name == enumerator_name) {
431 enum_type,
"result");
447 const bool check_ptr_vs_member =
449 const bool no_synth_child =
451 const bool allow_var_updates =
453 const bool disallow_globals =
462llvm::Expected<lldb::ValueObjectSP>
464 assert(tree &&
"ASTNodeUP must not contain a nullptr");
467 if (!value_or_error) {
468 auto error = value_or_error.takeError();
470 "[Interpreter::Evaluate] DIL interpreter failed:\n{0}",
471 llvm::toStringWithoutConsuming(
error));
475 return value_or_error;
480 auto value_or_error = node.
Accept(
this);
482 if (value_or_error && !*value_or_error)
483 return llvm::make_error<DILDiagnosticError>(
m_expr,
"invalid value object",
487 return value_or_error;
490llvm::Expected<lldb::ValueObjectSP>
492 auto valobj_or_err =
Evaluate(node);
494 return valobj_or_err;
498 if (valobj->GetCompilerType().IsReferenceType()) {
499 valobj = valobj->Dereference(
error);
501 return error.ToError();
506llvm::Expected<lldb::ValueObjectSP>
520 if (!identifier && node.
GetName()[0] ==
'$') {
523 return language.takeError();
528 if (!identifier && node.
GetName() ==
"nullptr") {
531 llvm::Expected<lldb::TypeSystemSP> type_system =
534 return type_system.takeError();
535 type_system.get()->GetPointerByteSize();
536 llvm::APInt value(type_system.get()->GetPointerByteSize() * CHAR_BIT, 0);
545 llvm::formatv(
"use of undeclared identifier '{0}'", node.
GetName());
546 return llvm::make_error<DILDiagnosticError>(
553llvm::Expected<lldb::ValueObjectSP>
566 operand = dynamic_op;
572 child_sp = synth_obj_sp->Dereference(
error);
576 return llvm::make_error<DILDiagnosticError>(
m_expr,
error.AsCString(),
585 return llvm::make_error<DILDiagnosticError>(
m_expr,
error.AsCString(),
591 if (operand->GetCompilerType().IsReferenceType()) {
592 operand = operand->Dereference(
error);
594 return error.ToError();
596 llvm::Expected<lldb::ValueObjectSP> conv_op =
604 llvm::formatv(
"invalid argument type '{0}' to unary expression",
606 return llvm::make_error<DILDiagnosticError>(
m_expr, errMsg,
610 bool resolved = operand->ResolveValue(scalar);
617 m_stack_frame, scalar, operand->GetCompilerType(),
"result");
621 if (operand->GetCompilerType().IsReferenceType()) {
622 operand = operand->Dereference(
error);
624 return error.ToError();
626 llvm::Expected<lldb::ValueObjectSP> conv_op =
636 llvm::formatv(
"invalid argument type '{0}' to unary expression",
638 return llvm::make_error<DILDiagnosticError>(
m_expr, errMsg,
644 if (operand->GetCompilerType().IsReferenceType()) {
645 operand = operand->Dereference(
error);
647 return error.ToError();
649 llvm::Expected<lldb::ValueObjectSP> conv_op =
657 llvm::formatv(
"invalid argument type '{0}' to unary expression",
659 return llvm::make_error<DILDiagnosticError>(
m_expr, errMsg,
663 bool resolved = operand->ResolveValue(scalar);
665 std::string errMsg = llvm::formatv(
"invalid operand value: {0}",
666 operand->GetError().AsCString());
667 return llvm::make_error<DILDiagnosticError>(
m_expr, errMsg,
674 m_stack_frame, scalar, operand->GetCompilerType(),
"result");
678 if (operand->GetCompilerType().IsReferenceType()) {
679 operand = operand->Dereference(
error);
681 return error.ToError();
686 llvm::formatv(
"invalid argument type '{0}' to unary expression",
688 return llvm::make_error<DILDiagnosticError>(
m_expr, errMsg,
691 llvm::Expected<lldb::TypeSystemSP> type_system =
694 return type_system.takeError();
695 auto value_or_err = operand->GetValueAsBool();
697 return value_or_err.takeError();
699 !(*value_or_err),
"result");
702 return llvm::make_error<DILDiagnosticError>(
m_expr,
"invalid unary operation",
706llvm::Expected<lldb::ValueObjectSP>
710 if (ptr->GetCompilerType().IsPointerToVoid())
711 return llvm::make_error<DILDiagnosticError>(
712 m_expr,
"arithmetic on a pointer to void", location);
713 if (ptr->GetValueAsUnsigned(0) == 0 && offset != 0)
714 return llvm::make_error<DILDiagnosticError>(
715 m_expr,
"arithmetic on a nullptr is undefined", location);
718 int64_t offset_int = offset->GetValueAsSigned(0, &success);
720 std::string errMsg = llvm::formatv(
"could not get the offset: {0}",
721 offset->GetError().AsCString());
722 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(errMsg),
726 llvm::Expected<uint64_t> byte_size =
727 ptr->GetCompilerType().GetPointeeType().GetByteSize(&
m_stack_frame);
729 return byte_size.takeError();
730 uint64_t ptr_addr = ptr->GetValueAsUnsigned(0);
732 ptr_addr -= offset_int * (*byte_size);
734 ptr_addr += offset_int * (*byte_size);
742llvm::Expected<lldb::ValueObjectSP>
747 bool l_resolved = lhs->ResolveValue(
l);
750 llvm::formatv(
"invalid lhs value: {0}", lhs->GetError().AsCString());
751 return llvm::make_error<DILDiagnosticError>(
m_expr, errMsg, location);
753 bool r_resolved = rhs->ResolveValue(r);
756 llvm::formatv(
"invalid rhs value: {0}", rhs->GetError().AsCString());
757 return llvm::make_error<DILDiagnosticError>(
m_expr, errMsg, location);
760 auto value_object = [
this, result_type](
Scalar scalar) {
762 result_type,
"result");
767 return value_object(
l + r);
769 return value_object(
l - r);
771 return value_object(
l * r);
773 return value_object(
l / r);
775 return value_object(
l % r);
777 return value_object(
l & r);
779 return value_object(
l ^ r);
781 return value_object(
l | r);
783 return value_object(
l << r);
785 return value_object(
l >> r);
787 return value_object(
l < r);
789 return value_object(
l > r);
791 return value_object(
l <= r);
793 return value_object(
l >= r);
795 return value_object(
l == r);
797 return value_object(
l != r);
801 return llvm::make_error<DILDiagnosticError>(
802 m_expr,
"invalid arithmetic operation", location);
811 auto orig_lhs_type = lhs->GetCompilerType();
812 auto orig_rhs_type = rhs->GetCompilerType();
815 return type_or_err.takeError();
824 if (lhs->GetCompilerType().IsPointerType()) {
827 }
else if (rhs->GetCompilerType().IsPointerType()) {
832 if (!ptr || !offset->GetCompilerType().IsInteger()) {
834 llvm::formatv(
"invalid operands to binary expression ('{0}' and '{1}')",
835 orig_lhs_type.GetTypeName(), orig_rhs_type.GetTypeName());
836 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(errMsg),
849 auto orig_lhs_type = lhs->GetCompilerType();
850 auto orig_rhs_type = rhs->GetCompilerType();
853 return type_or_err.takeError();
859 auto lhs_type = lhs->GetCompilerType();
860 auto rhs_type = rhs->GetCompilerType();
863 if (lhs_type.IsPointerType() && rhs_type.IsInteger())
867 if (lhs_type.IsPointerType() && rhs_type.IsPointerType()) {
868 if (lhs_type.IsPointerToVoid() && rhs_type.IsPointerToVoid()) {
869 return llvm::make_error<DILDiagnosticError>(
870 m_expr,
"arithmetic on pointers to void", location);
875 if (!lhs_unqualified_type.
CompareTypes(rhs_unqualified_type)) {
876 std::string errMsg = llvm::formatv(
877 "'{0}' and '{1}' are not pointers to compatible types",
878 orig_lhs_type.GetTypeName(), orig_rhs_type.GetTypeName());
879 return llvm::make_error<DILDiagnosticError>(
m_expr, errMsg, location);
882 llvm::Expected<uint64_t> lhs_byte_size =
885 return lhs_byte_size.takeError();
887 int64_t item_size = *lhs_byte_size;
888 int64_t diff =
static_cast<int64_t
>(lhs->GetValueAsUnsigned(0) -
889 rhs->GetValueAsUnsigned(0));
890 assert(item_size > 0 &&
"Pointee size cannot be 0");
891 if (diff % item_size != 0) {
894 return llvm::make_error<DILDiagnosticError>(
895 m_expr,
"undefined pointer arithmetic", location);
899 llvm::Expected<lldb::TypeSystemSP> type_system =
902 return type_system.takeError();
903 CompilerType ptrdiff_type = type_system.get()->GetPointerDiffType(
true);
905 return llvm::make_error<DILDiagnosticError>(
906 m_expr,
"unable to determine pointer diff type", location);
910 ptrdiff_type,
"result");
914 llvm::formatv(
"invalid operands to binary expression ('{0}' and '{1}')",
915 orig_lhs_type.GetTypeName(), orig_rhs_type.GetTypeName());
916 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(errMsg),
924 auto orig_lhs_type = lhs->GetCompilerType();
925 auto orig_rhs_type = rhs->GetCompilerType();
928 return type_or_err.takeError();
933 llvm::formatv(
"invalid operands to binary expression ('{0}' and '{1}')",
934 orig_lhs_type.GetTypeName(), orig_rhs_type.GetTypeName());
935 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(errMsg),
946 auto orig_lhs_type = lhs->GetCompilerType();
947 auto orig_rhs_type = rhs->GetCompilerType();
950 return type_or_err.takeError();
955 llvm::formatv(
"invalid operands to binary expression ('{0}' and '{1}')",
956 orig_lhs_type.GetTypeName(), orig_rhs_type.GetTypeName());
957 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(errMsg),
962 if (result_type.
IsInteger() && rhs->GetValueAsSigned(-1) == 0) {
963 return llvm::make_error<DILDiagnosticError>(
964 m_expr,
"division by zero is undefined", location);
974 auto orig_lhs_type = lhs->GetCompilerType();
975 auto orig_rhs_type = rhs->GetCompilerType();
978 return type_or_err.takeError();
983 llvm::formatv(
"invalid operands to binary expression ('{0}' and '{1}')",
984 orig_lhs_type.GetTypeName(), orig_rhs_type.GetTypeName());
985 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(errMsg),
989 if (rhs->GetValueAsSigned(-1) == 0) {
990 return llvm::make_error<DILDiagnosticError>(
991 m_expr,
"division by zero is undefined", location);
1007 return llvm::createStringError(
1008 "Illegal type for lhs of assignment (not scalar numeric type)");
1013 return llvm::createStringError(
1014 "Illegal type for rhs of assignment (not scalar numeric type)");
1019 return llvm::createStringError(
1020 "Invalid assignment: Can only assign pointers to pointers");
1025 lhs_type != rhs_type) {
1026 std::string err_msg =
1027 llvm::formatv(
"Incompatible types for assignment: Cannot assign {0} "
1030 return llvm::createStringError(err_msg);
1036llvm::Expected<lldb::ValueObjectSP>
1041 if (llvm::Error err = lhs->CanSetValue())
1047 return all_ok.takeError();
1056 bool is_zero = val->GetValueAsUnsigned(-1) == 0;
1057 bool is_boolean = val->GetCompilerType().IsBoolean();
1058 return is_zero && !is_boolean && is_literal;
1064 bool rhs_is_literal, uint32_t location) {
1065 auto orig_lhs_type = lhs->GetCompilerType();
1066 auto orig_rhs_type = rhs->GetCompilerType();
1070 bool lhs_nullptr_or_zero =
1071 orig_lhs_type.IsNullPtrType() ||
IsLiteralZero(lhs, lhs_is_literal);
1072 bool rhs_nullptr_or_zero =
1073 orig_rhs_type.IsNullPtrType() ||
IsLiteralZero(rhs, rhs_is_literal);
1075 if (orig_lhs_type.IsArrayType())
1077 if (orig_rhs_type.IsArrayType())
1083 if (lhs_type == rhs_type)
1084 return llvm::Error::success();
1094 lhs_child = lhs->GetChildAtIndex(0);
1095 if (lhs_child && (lhs_child->IsPointerType() ||
1096 lhs_child->GetCompilerType().IsNullPtrType()))
1097 lhs_type = lhs_child->GetCompilerType();
1103 rhs_child = rhs->GetChildAtIndex(0);
1104 if (rhs_child && (rhs_child->IsPointerType() ||
1105 rhs_child->GetCompilerType().IsNullPtrType()))
1106 rhs_type = rhs_child->GetCompilerType();
1109 if ((lhs_type != orig_lhs_type) || (rhs_type != orig_rhs_type)) {
1111 return llvm::Error::success();
1115 return llvm::Error::success();
1123 return llvm::Error::success();
1127 bool comparable = lhs_unqualified.
CompareTypes(rhs_unqualified);
1129 return llvm::Error::success();
1131 std::string errMsg = llvm::formatv(
1132 "comparison of distinct pointer types ({0} and {1})",
1133 orig_lhs_type.TypeDescription(), orig_rhs_type.TypeDescription());
1134 return llvm::make_error<DILDiagnosticError>(
m_expr, errMsg, location);
1137 if (!is_ordered && ((orig_lhs_type.IsNullPtrType() && rhs_nullptr_or_zero) ||
1138 (lhs_nullptr_or_zero && orig_rhs_type.IsNullPtrType())))
1139 return llvm::Error::success();
1146 return type_or_err.takeError();
1148 lhs_type = lhs->GetCompilerType();
1149 rhs_type = rhs->GetCompilerType();
1152 return llvm::Error::success();
1158 return llvm::Error::success();
1159 std::string errMsg = llvm::formatv(
1160 "invalid operands to binary expression ({0} and {1})",
1161 orig_lhs_type.TypeDescription(), orig_rhs_type.TypeDescription());
1162 return llvm::make_error<DILDiagnosticError>(
m_expr, errMsg, location);
1171 return t.IsPointerType() || t.IsInteger() ||
1172 t.IsUnscopedEnumerationType() || (!is_ordered && t.IsNullPtrType());
1175 if ((lhs_type.
IsPointerType() && comparable_to_pointer(rhs_type)) ||
1176 (comparable_to_pointer(lhs_type) && rhs_type.
IsPointerType())) {
1185 bool comparable = lhs_unqualified_type.
CompareTypes(rhs_unqualified_type);
1189 std::string errMsg = llvm::formatv(
1190 "comparison of distinct pointer types ({0} and {1})",
1191 orig_lhs_type.TypeDescription(), orig_rhs_type.TypeDescription());
1192 return llvm::make_error<DILDiagnosticError>(
m_expr, errMsg, location);
1196 return llvm::Error::success();
1199 std::string errMsg = llvm::formatv(
1200 "invalid operands to binary expression ({0} and {1})",
1201 orig_lhs_type.TypeDescription(), orig_rhs_type.TypeDescription());
1202 return llvm::make_error<DILDiagnosticError>(
m_expr, errMsg, location);
1205llvm::Expected<lldb::ValueObjectSP>
1208 bool rhs_is_literal, uint32_t location) {
1218 rhs_is_literal, location))
1221 llvm::Expected<lldb::TypeSystemSP> type_system =
1224 return type_system.takeError();
1230llvm::Expected<lldb::ValueObjectSP>
1235 auto orig_lhs_type = lhs->GetCompilerType();
1236 auto orig_rhs_type = rhs->GetCompilerType();
1239 return type_or_err.takeError();
1243 std::string errMsg =
1244 llvm::formatv(
"invalid operands to binary expression ('{0}' and '{1}')",
1245 orig_lhs_type.GetTypeName(), orig_rhs_type.GetTypeName());
1246 return llvm::make_error<DILDiagnosticError>(
m_expr, errMsg, location);
1252llvm::Expected<lldb::ValueObjectSP>
1261 return lhs_or_err.takeError();
1265 return rhs_or_err.takeError();
1271 std::string errMsg =
1272 llvm::formatv(
"invalid operands to binary expression ('{0}' and '{1}')",
1274 return llvm::make_error<DILDiagnosticError>(
m_expr, errMsg, location);
1278 uint64_t amount = rhs->GetValueAsUnsigned(0, &success);
1280 return llvm::make_error<DILDiagnosticError>(
1281 m_expr,
"could not get the shift amount as an integer", location);
1284 return lhs_size.takeError();
1285 if (amount >= *lhs_size)
1286 return llvm::make_error<DILDiagnosticError>(
m_expr,
"invalid shift amount",
1292llvm::Expected<lldb::ValueObjectSP>
1302 auto lhs_type = lhs->GetCompilerType();
1303 if (!lhs_type.IsContextuallyConvertibleToBool()) {
1304 std::string errMsg = llvm::formatv(
1305 "value of type {0} is not contextually convertible to 'bool'",
1306 lhs_type.TypeDescription());
1307 return llvm::make_error<DILDiagnosticError>(
m_expr, errMsg,
1310 llvm::Expected<lldb::TypeSystemSP> type_system =
1313 return type_system.takeError();
1317 auto lvalue_or_err = lhs->GetValueAsBool();
1319 return lvalue_or_err.takeError();
1320 bool lhs_val = *lvalue_or_err;
1331 auto rhs_type = rhs->GetCompilerType();
1332 if (!rhs_type.IsContextuallyConvertibleToBool()) {
1333 std::string errMsg = llvm::formatv(
1334 "value of type {0} is not contextually convertible to 'bool'",
1335 rhs_type.TypeDescription());
1336 return llvm::make_error<DILDiagnosticError>(
m_expr, errMsg,
1340 auto rvalue_or_err = rhs->GetValueAsBool();
1342 return rvalue_or_err.takeError();
1344 *rvalue_or_err,
"result");
1347llvm::Expected<lldb::ValueObjectSP>
1366 lhs->GetCompilerType().GetTypeSystem().GetSharedPointer();
1368 rhs->GetCompilerType().GetTypeSystem().GetSharedPointer();
1369 if (lhs_system->GetPluginName() != rhs_system->GetPluginName()) {
1371 return llvm::make_error<DILDiagnosticError>(
1473 return llvm::make_error<DILDiagnosticError>(
1477llvm::Expected<lldb::ValueObjectSP>
1489 if (!base->IsPointerType() && base->HasSyntheticValue()) {
1492 base->GetSyntheticValue()->Dereference(deref_error);
1493 synth_deref_sp && deref_error.
Success()) {
1494 base = std::move(synth_deref_sp);
1496 if (!base || deref_error.
Fail()) {
1497 std::string errMsg = llvm::formatv(
1498 "Failed to dereference synthetic value: {0}", deref_error);
1499 return llvm::make_error<DILDiagnosticError>(
1505 std::string errMsg =
"Failed to dereference synthetic value";
1506 return llvm::make_error<DILDiagnosticError>(
1509 expr_is_ptr =
false;
1514 bool base_is_ptr = base->IsPointerType();
1516 if (expr_is_ptr != base_is_ptr) {
1518 std::string errMsg =
1519 llvm::formatv(
"member reference type {0} is a pointer; "
1520 "did you mean to use '->'?",
1521 base->GetCompilerType().TypeDescription());
1522 return llvm::make_error<DILDiagnosticError>(
1525 std::string errMsg =
1526 llvm::formatv(
"member reference type {0} is not a pointer; "
1527 "did you mean to use '.'?",
1528 base->GetCompilerType().TypeDescription());
1529 return llvm::make_error<DILDiagnosticError>(
1539 field_obj = base->GetSyntheticValue();
1541 field_obj = field_obj->GetChildMemberWithName(node.
GetFieldName());
1545 std::string errMsg = llvm::formatv(
1546 "\"{0}\" is not a member of \"({1}) {2}\"", node.
GetFieldName(),
1547 base->GetTypeName().AsCString(
"<invalid type>"), base->GetName());
1548 return llvm::make_error<DILDiagnosticError>(
1558 field_obj = dynamic_val_sp;
1564 if (node.
GetIsArrow() && base->IsPointerType())
1566 std::string errMsg = llvm::formatv(
1567 "\"{0}\" is not a member of \"({1}) {2}\"", node.
GetFieldName(),
1568 base->GetTypeName().AsCString(
"<invalid type>"), base->GetName());
1569 return llvm::make_error<DILDiagnosticError>(
1573llvm::Expected<lldb::ValueObjectSP>
1580 if (!idx->GetCompilerType().IsIntegerOrUnscopedEnumerationType()) {
1581 return llvm::make_error<DILDiagnosticError>(
1586 uint64_t child_idx = idx->GetValueAsUnsigned(0);
1594 CompilerType base_type = base->GetCompilerType().GetNonReferenceType();
1595 base->GetExpressionPath(var_expr_path_strm);
1596 bool is_incomplete_array =
false;
1598 bool is_objc_pointer =
true;
1601 is_objc_pointer =
false;
1602 else if (!base->GetCompilerType().IsPointerType())
1603 is_objc_pointer =
false;
1606 std::string err_msg = llvm::formatv(
1607 "\"({0}) {1}\" is an Objective-C pointer, and cannot be subscripted",
1608 base->GetTypeName().AsCString(
"<invalid type>"),
1609 var_expr_path_strm.
GetData());
1610 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(err_msg),
1613 if (is_objc_pointer) {
1615 if (!synthetic || synthetic == base) {
1616 std::string err_msg =
1617 llvm::formatv(
"\"({0}) {1}\" is not an array type",
1618 base->GetTypeName().AsCString(
"<invalid type>"),
1619 var_expr_path_strm.
GetData());
1620 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(err_msg),
1623 if (
static_cast<uint32_t
>(child_idx) >=
1624 synthetic->GetNumChildrenIgnoringErrors()) {
1625 std::string err_msg = llvm::formatv(
1626 "array index {0} is not valid for \"({1}) {2}\"", child_idx,
1627 base->GetTypeName().AsCString(
"<invalid type>"),
1628 var_expr_path_strm.
GetData());
1629 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(err_msg),
1632 child_valobj_sp = synthetic->GetChildAtIndex(child_idx);
1633 if (!child_valobj_sp) {
1634 std::string err_msg = llvm::formatv(
1635 "array index {0} is not valid for \"({1}) {2}\"", child_idx,
1636 base->GetTypeName().AsCString(
"<invalid type>"),
1637 var_expr_path_strm.
GetData());
1638 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(err_msg),
1642 if (
auto dynamic_sp = child_valobj_sp->GetDynamicValue(
m_use_dynamic))
1643 child_valobj_sp = std::move(dynamic_sp);
1645 return child_valobj_sp;
1648 child_valobj_sp = base->GetSyntheticArrayMember(child_idx,
true);
1649 if (!child_valobj_sp) {
1650 std::string err_msg = llvm::formatv(
1651 "failed to use pointer as array for index {0} for "
1653 child_idx, base->GetTypeName().AsCString(
"<invalid type>"),
1654 var_expr_path_strm.
GetData());
1656 err_msg =
"subscript of pointer to incomplete type 'void'";
1657 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(err_msg),
1660 }
else if (base_type.
IsArrayType(
nullptr,
nullptr, &is_incomplete_array)) {
1661 child_valobj_sp = base->GetChildAtIndex(child_idx);
1663 child_valobj_sp = base->GetSyntheticArrayMember(child_idx,
true);
1664 if (!child_valobj_sp) {
1665 std::string err_msg = llvm::formatv(
1666 "array index {0} is not valid for \"({1}) {2}\"", child_idx,
1667 base->GetTypeName().AsCString(
"<invalid type>"),
1668 var_expr_path_strm.
GetData());
1669 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(err_msg),
1674 base->GetSyntheticBitFieldChild(child_idx, child_idx,
true);
1675 if (!child_valobj_sp) {
1676 std::string err_msg = llvm::formatv(
1677 "bitfield range {0}:{1} is not valid for \"({2}) {3}\"", child_idx,
1678 child_idx, base->GetTypeName().AsCString(
"<invalid type>"),
1679 var_expr_path_strm.
GetData());
1680 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(err_msg),
1686 std::string err_msg =
1687 llvm::formatv(
"\"{0}\" is not an array type",
1688 base->GetTypeName().AsCString(
"<invalid type>"));
1689 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(err_msg),
1692 if (
static_cast<uint32_t
>(child_idx) >=
1693 synthetic->GetNumChildrenIgnoringErrors(child_idx + 1)) {
1694 std::string err_msg = llvm::formatv(
1695 "array index {0} is not valid for \"({1}) {2}\"", child_idx,
1696 base->GetTypeName().AsCString(
"<invalid type>"),
1697 var_expr_path_strm.
GetData());
1698 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(err_msg),
1701 child_valobj_sp = synthetic->GetChildAtIndex(child_idx);
1702 if (!child_valobj_sp) {
1703 std::string err_msg = llvm::formatv(
1704 "array index {0} is not valid for \"({1}) {2}\"", child_idx,
1705 base->GetTypeName().AsCString(
"<invalid type>"),
1706 var_expr_path_strm.
GetData());
1707 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(err_msg),
1712 if (child_valobj_sp) {
1714 if (
auto dynamic_sp = child_valobj_sp->GetDynamicValue(
m_use_dynamic))
1715 child_valobj_sp = std::move(dynamic_sp);
1717 return child_valobj_sp;
1721 int64_t signed_child_idx = idx->GetValueAsSigned(0, &success);
1723 return llvm::make_error<DILDiagnosticError>(
1724 m_expr,
"could not get the index as an integer",
1726 return base->GetSyntheticArrayMember(signed_child_idx,
true);
1729llvm::Expected<lldb::ValueObjectSP>
1732 if (!first_idx_or_err)
1733 return first_idx_or_err;
1736 if (!last_idx_or_err)
1737 return last_idx_or_err;
1740 if (!first_idx->GetCompilerType().IsIntegerOrUnscopedEnumerationType() ||
1741 !last_idx->GetCompilerType().IsIntegerOrUnscopedEnumerationType()) {
1742 return llvm::make_error<DILDiagnosticError>(
1746 bool success_first, success_last;
1747 int64_t first_index = first_idx->GetValueAsSigned(0, &success_first);
1748 int64_t last_index = last_idx->GetValueAsSigned(0, &success_last);
1749 if (!success_first || !success_last)
1750 return llvm::make_error<DILDiagnosticError>(
1756 if (first_index < 0 || last_index < 0) {
1757 std::string message =
1758 llvm::formatv(
"bitfield range {0}:{1} is not valid (negative index)",
1759 first_index, last_index);
1760 return llvm::make_error<DILDiagnosticError>(
m_expr, message,
1765 if (first_index > last_index)
1766 std::swap(first_index, last_index);
1771 if (last_index - first_index >= 64) {
1772 std::string message =
1773 llvm::formatv(
"bitfield range {0}:{1} is not valid (more than 64 bits)",
1774 first_index, last_index);
1775 return llvm::make_error<DILDiagnosticError>(
m_expr, message,
1787 llvm::Expected<uint64_t> base_bit_size =
1790 return base_bit_size.takeError();
1791 if (
static_cast<uint64_t
>(last_index) >= *base_bit_size) {
1792 std::string message = llvm::formatv(
1793 "bitfield range {0}:{1} is not valid for \"({2}) {3}\"", first_index,
1794 last_index, base->GetTypeName().AsCString(
"<invalid type>"),
1795 base->GetName().GetStringRef());
1796 return llvm::make_error<DILDiagnosticError>(
m_expr, message,
1801 base->GetSyntheticBitFieldChild(first_index, last_index,
true);
1802 if (!child_valobj_sp) {
1803 std::string message = llvm::formatv(
1804 "bitfield range {0}:{1} is not valid for \"({2}) {3}\"", first_index,
1805 last_index, base->GetTypeName().AsCString(
"<invalid type>"),
1806 base->GetName().GetStringRef());
1807 return llvm::make_error<DILDiagnosticError>(
m_expr, message,
1810 return child_valobj_sp;
1813llvm::Expected<CompilerType>
1820 llvm::APInt apint = literal.
GetValue();
1822 llvm::SmallVector<std::pair<lldb::BasicType, lldb::BasicType>, 3> candidates;
1833 for (
auto [signed_, unsigned_] : candidates) {
1834 CompilerType signed_type = type_system->GetBasicTypeFromAST(signed_);
1837 llvm::Expected<uint64_t> size = signed_type.
GetBitSize(&ctx);
1839 return size.takeError();
1840 if (!literal.
IsUnsigned() && apint.isIntN(*size - 1))
1843 return type_system->GetBasicTypeFromAST(unsigned_);
1846 return llvm::make_error<DILDiagnosticError>(
1848 "integer literal is too large to be represented in any integer type",
1852llvm::Expected<lldb::ValueObjectSP>
1854 llvm::Expected<lldb::TypeSystemSP> type_system =
1857 return type_system.takeError();
1859 llvm::Expected<CompilerType> type =
1862 return type.takeError();
1867 llvm::Expected<uint64_t> type_bitsize = type->GetBitSize(&
m_stack_frame);
1869 return type_bitsize.takeError();
1873 if (type->IsSigned())
1879llvm::Expected<lldb::ValueObjectSP>
1881 llvm::Expected<lldb::TypeSystemSP> type_system =
1884 return type_system.takeError();
1887 &node.
GetValue().getSemantics() == &llvm::APFloat::IEEEsingle();
1893 return llvm::make_error<DILDiagnosticError>(
1901llvm::Expected<lldb::ValueObjectSP>
1904 llvm::Expected<lldb::TypeSystemSP> type_system =
1907 return type_system.takeError();
1912llvm::Expected<CastKind>
1917 if (target_type.
GetTypeInfo() & lldb::eTypeIsFloat) {
1918 std::string errMsg = llvm::formatv(
"Cast from {0} to {1} is not allowed",
1921 return llvm::make_error<DILDiagnosticError>(
1922 m_expr, std::move(errMsg), location,
1932 uint64_t type_byte_size = 0;
1933 uint64_t rhs_type_byte_size = 0;
1935 type_byte_size = *temp;
1937 std::string errMsg = llvm::formatv(
"unable to get byte size for type {0}",
1940 "GetByteSize failed: {0}");
1941 return llvm::make_error<DILDiagnosticError>(
1942 m_expr, std::move(errMsg), location,
1947 rhs_type_byte_size = *temp;
1949 std::string errMsg = llvm::formatv(
"unable to get byte size for type {0}",
1952 "GetByteSize failed: {0}");
1953 return llvm::make_error<DILDiagnosticError>(
1954 m_expr, std::move(errMsg), location,
1958 if (type_byte_size < rhs_type_byte_size) {
1959 std::string errMsg = llvm::formatv(
1960 "cast from pointer to smaller type {0} loses information",
1962 return llvm::make_error<DILDiagnosticError>(
1963 m_expr, std::move(errMsg), location,
1968 std::string errMsg = llvm::formatv(
"cannot convert {0} to {1}",
1972 return llvm::make_error<DILDiagnosticError>(
1973 m_expr, std::move(errMsg), location,
1979llvm::Expected<CastKind>
1990 std::string errMsg = llvm::formatv(
"Cast from {0} to {1} is not allowed",
1994 return llvm::make_error<DILDiagnosticError>(
1995 m_expr, std::move(errMsg), location,
2005 std::string errMsg = llvm::formatv(
2006 "cannot cast from type {0} to pointer type {1}",
2009 return llvm::make_error<DILDiagnosticError>(
2010 m_expr, std::move(errMsg), location,
2017 std::string errMsg = llvm::formatv(
2018 "casting of {0} to {1} is not implemented yet",
2020 return llvm::make_error<DILDiagnosticError>(
2021 m_expr, std::move(errMsg), location,
2028 if (!operand_or_err)
2029 return operand_or_err;
2039 operand->GetName().GetStringRef());
2040 op_type = operand->GetCompilerType();
2045 return type_or_err.takeError();
2048 if (operand->GetCompilerType().IsReferenceType()) {
2050 operand = operand->Dereference(
error);
2052 return llvm::make_error<DILDiagnosticError>(
m_expr,
error.AsCString(),
2057 switch (cast_kind) {
2062 result = operand->CastToEnumType(target_type);
2068 result = operand->CastToBasicType(target_type);
2073 ? operand->GetLoadAddress()
2074 : (op_type.
IsSigned() ? operand->GetValueAsSigned(0)
2075 : operand->GetValueAsUnsigned(0));
2088 if (result->GetError().Fail())
2089 return llvm::make_error<DILDiagnosticError>(
2094 std::string errMsg =
2095 llvm::formatv(
"unable to cast from '{0}' to '{1}'",
2097 return llvm::make_error<DILDiagnosticError>(
m_expr, std::move(errMsg),
2101llvm::Expected<lldb::ValueObjectSP>
2110 std::string errMsg = llvm::formatv(
2111 "value of type {0} is not contextually convertible to 'bool'",
2113 return llvm::make_error<DILDiagnosticError>(
m_expr, errMsg,
2118 auto value_or_err = condition->GetValueAsBool();
2120 if (*value_or_err) {
2124 return *true_or_err;
2128 return false_or_err;
2129 return *false_or_err;
2131 return value_or_err.takeError();
2142 return byte_size.takeError();
2150 if (arg->IsBitfield())
2151 return llvm::make_error<DILDiagnosticError>(
2152 m_expr,
"invalid application of 'sizeof' to bit-field",
2155 llvm::Expected<uint64_t> byte_size = arg->GetByteSize();
2157 return byte_size.takeError();
2161 llvm::Expected<lldb::TypeSystemSP> type_system =
2164 return type_system.takeError();
2165 CompilerType size_type = type_system.get()->GetSizeType();
2167 return llvm::make_error<DILDiagnosticError>(
2171 size_type,
"result");
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOG_ERROR(log, error,...)
lldb::VariableListSP GetVariableList(bool can_create)
Get the variable list for a compile unit.
lldb::LanguageType GetLanguage()
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
bool IsScalarOrUnscopedEnumerationType() const
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
bool IsContextuallyConvertibleToBool() const
This may only be defined in TypeSystemClang.
llvm::Expected< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
bool IsPointerToVoid() const
void ForEachEnumerator(std::function< bool(const CompilerType &integer_type, ConstString name, const llvm::APSInt &value)> const &callback) const
If this type is an enumeration, iterate through all of its enumerators using a callback.
bool IsIntegerOrEnumerationType(bool &is_signed) const
bool IsScopedEnumerationType() 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 GetFullyUnqualifiedType() const
CompilerType GetPointeeType() const
If this type is a pointer type, return the type that the pointer points to, else return an invalid ty...
bool IsUnscopedEnumerationType() const
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.
This base class provides an interface to stack frames.
@ eExpressionPathOptionCheckPtrVsMember
@ eExpressionPathOptionsDisallowGlobals
@ eExpressionPathOptionsAllowVarUpdates
@ eExpressionPathOptionsNoSyntheticChildren
virtual const char * GetFunctionName()
Get the frame's demangled name.
virtual lldb::RegisterContextSP GetRegisterContext()
Get the RegisterContext for this frame, if possible.
virtual lldb::ValueObjectSP GetValueObjectForFrameVariable(const lldb::VariableSP &variable_sp, lldb::DynamicValueType use_dynamic)
Create a ValueObject for a given Variable in this StackFrame.
virtual const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
virtual lldb::VariableListSP GetInScopeVariableList(bool get_file_globals, bool include_synthetic_vars=true, bool must_have_valid_location=false)
Retrieve the list of variables that are in scope at this StackFrame's pc.
virtual lldb::ValueObjectSP FindVariable(ConstString name)
Attempt to reconstruct the ValueObject for a variable with a given name from within the current Stack...
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 GetInstanceName()
Determines the name of the instance for this decl context.
lldb::ModuleSP module_sp
The Module for a given query.
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 CreateValueObjectFromScalar(const ExecutionContext &exe_ctx, Scalar &s, CompilerType type, llvm::StringRef name, ValueObject *parent=nullptr)
Create a value object containing the given Scalar value.
static lldb::ValueObjectSP CreateValueObjectFromBool(const ExecutionContext &exe_ctx, lldb::TypeSystemSP typesystem, bool value, llvm::StringRef name, ValueObject *parent=nullptr)
Create a value object containing the given boolean value.
lldb::addr_t GetLoadAddress()
Return the target load address associated with this value object.
CompilerType GetCompilerType()
static lldb::ValueObjectSP CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx, CompilerType type, bool do_deref=true, ValueObject *parent=nullptr)
Given an address either create a value object containing the value at that address,...
The rest of the classes in this file, except for the Visitor class at the very end,...
uint32_t GetLocation() const
virtual bool IsConstLiteral() 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
ASTNode & GetFalseOperand() const
ASTNode & GetTrueOperand() const
ASTNode & GetCondition() const
const llvm::APFloat & GetValue() const
std::string GetName() const
uint32_t GetRadix() const
IntegerTypeSuffix GetTypeSuffix() const
const llvm::APInt & GetValue() const
llvm::Expected< lldb::ValueObjectSP > EvaluateBinaryRemainder(lldb::ValueObjectSP lhs, lldb::ValueObjectSP rhs, uint32_t location)
llvm::Error ValidateComparison(BinaryOpKind kind, lldb::ValueObjectSP &lhs, lldb::ValueObjectSP &rhs, bool lhs_is_literal, bool rhs_is_literal, uint32_t location)
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 > EvaluateBinaryShift(BinaryOpKind kind, lldb::ValueObjectSP lhs, lldb::ValueObjectSP rhs, uint32_t location)
llvm::Expected< lldb::ValueObjectSP > EvaluateLogical(const BinaryOpNode &node)
llvm::Expected< lldb::ValueObjectSP > EvaluateTree(const ASTNodeUP &tree)
Evaluate an ASTNode tree.
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 > EvaluateComparison(BinaryOpKind kind, lldb::ValueObjectSP lhs, lldb::ValueObjectSP rhs, bool lhs_is_literal, bool rhs_is_literal, uint32_t location)
llvm::Expected< lldb::ValueObjectSP > Visit(const IdentifierNode &node) override
bool m_check_ptr_vs_member
llvm::Expected< lldb::ValueObjectSP > EvaluateBinaryDivision(lldb::ValueObjectSP lhs, lldb::ValueObjectSP rhs, uint32_t location)
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< lldb::ValueObjectSP > EvaluateBinaryMultiplication(lldb::ValueObjectSP lhs, lldb::ValueObjectSP rhs, uint32_t location)
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...
Interpreter(lldb::TargetSP target, llvm::StringRef expr, StackFrame &stack_frame, lldb::DynamicValueType use_dynamic, uint32_t options)
llvm::Expected< CompilerType > PickIntegerType(lldb::TypeSystemSP type_system, ExecutionContextScope &ctx, const IntegerLiteralNode &literal)
llvm::Expected< lldb::ValueObjectSP > EvaluateAssignment(lldb::ValueObjectSP lhs, lldb::ValueObjectSP rhs, uint32_t location)
llvm::Expected< CastKind > VerifyArithmeticCast(CompilerType source_type, CompilerType target_type, int location)
A helper function for VerifyCastType (below).
llvm::Expected< lldb::ValueObjectSP > EvaluateBinaryBitwise(BinaryOpKind kind, lldb::ValueObjectSP lhs, lldb::ValueObjectSP rhs, uint32_t location)
StackFrame & m_stack_frame
llvm::StringRef GetFieldName() const
ASTNode & GetBase() const
ASTNode & GetNodeArg() const
CompilerType GetTypeArg() 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.
lldb::ValueObjectSP LookupPersistentIdentifier(llvm::StringRef name_ref, StackFrame &stack_frame, lldb::TargetSP target_sp, lldb::LanguageType language)
Given the name of a persistent identifier (i.e., one that starts with a $), find the ValueObject for ...
static lldb::BasicType BasicTypeToUnsigned(lldb::BasicType basic_type)
static bool IsLiteralZero(lldb::ValueObjectSP &val, bool is_literal)
static llvm::Expected< lldb::TypeSystemSP > GetTypeSystemFromCU(StackFrame &ctx)
lldb::ValueObjectSP LookupIdentifier(llvm::StringRef name_ref, StackFrame &stack_frame, lldb::DynamicValueType use_dynamic)
Given the name of an identifier (variable name, member name, type name, etc.), find the ValueObject f...
static CompilerType GetBasicType(lldb::TypeSystemSP type_system, lldb::BasicType basic_type)
static lldb::ValueObjectSP ArrayToPointerConversion(ValueObject &valobj, ExecutionContextScope &ctx, llvm::StringRef name)
std::unique_ptr< ASTNode > ASTNodeUP
BinaryOpKind
The binary operators recognized by DIL.
lldb::ValueObjectSP LookupGlobalIdentifier(llvm::StringRef name_ref, StackFrame &stack_frame, 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.
static llvm::Expected< bool > VerifyAssignmentTypes(CompilerType lhs_type, CompilerType rhs_type)
lldb::ValueObjectSP LookupEnumValue(llvm::StringRef name_ref, ExecutionContextScope &ctx_scope)
Given the name of an identifier, attempt to find an enumeration value.
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)
CompilerType ResolveTypeByName(const std::string &name, ExecutionContextScope &ctx_scope)
static bool HasFloatingRepresentation(CompilerType ct)
static llvm::Expected< lldb::LanguageType > GetSourceLanguageFromCU(StackFrame &ctx)
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
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
LanguageType
Programming language type.
@ 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),...