================
@@ -1342,14 +1277,53 @@ Interpreter::Visit(const BitFieldExtractionNode &node) {
return llvm::make_error<DILDiagnosticError>(
m_expr, "could not get the index as an integer", node.GetLocation());
+ // Reject negative indices before the swap below, so the diagnostic reports
+ // the range as the user wrote it. A negative index would also wrap to a huge
+ // offset in the uint32_t GetSyntheticBitFieldChild call below.
+ if (first_index < 0 || last_index < 0) {
+ std::string message =
+ llvm::formatv("bitfield range {0}:{1} is not valid (negative index)",
+ first_index, last_index);
+ return llvm::make_error<DILDiagnosticError>(m_expr, message,
+ node.GetLocation());
+ }
+
// if the format given is [high-low], swap range
if (first_index > last_index)
std::swap(first_index, last_index);
+ // GetMaxU64Bitfield in the data layer only supports up to 64 bits (it
asserts
+ // bitfield_bit_size <= 64 and otherwise shifts out of bounds), so reject a
+ // wider range here.
+ if (last_index - first_index + 1 > 64) {
----------------
qiyao wrote:
Good catch, fixed.
https://github.com/llvm/llvm-project/pull/213055
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits