[Lldb-commits] [lldb] [LLDB] Add assignment to DIL. (PR #190223)
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Tue Jun 2 12:48:16 PDT 2026
================
@@ -801,6 +803,60 @@ llvm::Expected<lldb::ValueObjectSP> Interpreter::EvaluateBinaryRemainder(
return EvaluateScalarOp(BinaryOpKind::Rem, lhs, rhs, result_type, location);
}
+static bool HasFloatingRepresentation(CompilerType ct) {
+ return ct.GetTypeInfo() & lldb::eTypeIsFloat;
+}
+
+static llvm::Expected<bool> VerifyAssignmentTypes(CompilerType lhs_type,
+ CompilerType rhs_type) {
+ // Make sure lhs is a legal type for DIL assignment.
+ if (!lhs_type.IsInteger() && !lhs_type.IsUnscopedEnumerationType() &&
+ !HasFloatingRepresentation(lhs_type) && !lhs_type.IsPointerType() &&
+ !lhs_type.IsScalarType())
+ return llvm::createStringError(
+ "Illegal type for lhs of assignment (not scalar numeric type)\n");
+
+ // Make sure rhs is a legal type for DIL assignment.
+ if (!rhs_type.IsInteger() && !rhs_type.IsUnscopedEnumerationType() &&
+ !HasFloatingRepresentation(rhs_type) && !rhs_type.IsPointerType())
+ return llvm::createStringError(
+ "Illegal type for rhs of assignment (not scalar numeric type)\n");
+
+ // Only allow assigning pointers to pointers.
+ if ((lhs_type.IsPointerType() && !rhs_type.IsPointerType()) ||
+ (!lhs_type.IsPointerType() && rhs_type.IsPointerType()))
+ return llvm::createStringError(
+ "Invalid assignment: Can only assign pointers to pointers\n");
+
+ // For "real numbers", the types must match exactly.
+ if ((HasFloatingRepresentation(rhs_type) ||
+ HasFloatingRepresentation(lhs_type)) &&
+ lhs_type != rhs_type) {
+ std::string err_msg =
+ llvm::formatv("Incompatible types for assignment: Cannot assign {0} "
----------------
adrian-prantl wrote:
Is the `Incompatible types for assignment: ` prefix necessary? It seems to be redundant with the remainder of the message.
https://github.com/llvm/llvm-project/pull/190223
More information about the lldb-commits
mailing list