Fixing potential int overflow and uninitialized variables.
These were found by Coverity static code inspection.
Differential Revision: https://reviews.llvm.org/D130795
imm = imm12;
break;
case 1:
- imm = imm12 << 12;
+ imm = static_cast<uint64_t>(imm12) << 12;
break;
default:
return false; // UNDEFINED;
static inline uint64_t GetStatusBit(uint32_t wp_index) {
// DR6: ...BBBB
// 3210 <- status bits for bp./wp. i; 1 if hit
- return 1 << wp_index;
+ return 1ULL << wp_index;
}
// Returns mask/value for global enable bit of wp_index in DR7
// 33221100 <- global/local enable for bp./wp.; 1 if enabled
// we use global bits because NetBSD kernel does not preserve local
// bits reliably; Linux seems fine with either
- return 1 << (2 * wp_index + 1);
+ return 1ULL << (2 * wp_index + 1);
}
// Returns mask for both enable bits of wp_index in DR7
static inline uint64_t GetBothEnableBitMask(uint32_t wp_index) {
// DR7: ...GLGLGLGL
// 33221100 <- global/local enable for bp./wp.; 1 if enabled
- return 3 << (2 * wp_index + 1);
+ return 3ULL << (2 * wp_index + 1);
}
// Returns value for type bits of wp_index in DR7
// wp.: 3333222211110000...
//
// where T - type is 01 for write, 11 for r/w
- return watch_flags << (16 + 4 * wp_index);
+ return static_cast<uint64_t>(watch_flags) << (16 + 4 * wp_index);
}
// Returns value for size bits of wp_index in DR7
// 01 for 2 bytes
// 10 for 8 bytes
// 11 for 4 bytes
- return (size == 8 ? 0x2 : size - 1) << (18 + 4 * wp_index);
+ return static_cast<uint64_t>(size == 8 ? 0x2 : size - 1)
+ << (18 + 4 * wp_index);
}
// Returns bitmask for all bits controlling wp_index in DR7
uint64_t field_bit_offset = (attrs.member_byte_offset == UINT32_MAX
? 0
- : (attrs.member_byte_offset * 8));
+ : (attrs.member_byte_offset * 8ULL));
if (attrs.bit_size > 0) {
FieldInfo this_field_info;
dw_addr_t DWARFUnit::ReadAddressFromDebugAddrSection(uint32_t index) const {
uint32_t index_size = GetAddressByteSize();
dw_offset_t addr_base = GetAddrBase();
- dw_addr_t offset = addr_base + index * index_size;
+ dw_addr_t offset = addr_base + static_cast<dw_addr_t>(index) * index_size;
const DWARFDataExtractor &data =
m_dwarf.GetDWARFContext().getOrLoadAddrData();
if (data.ValidOffsetForDataOfSize(offset, index_size))
GetAddressByteSize(), [&](uint32_t index) {
uint32_t index_size = GetAddressByteSize();
dw_offset_t addr_base = GetAddrBase();
- lldb::offset_t offset = addr_base + index * index_size;
+ lldb::offset_t offset =
+ addr_base + static_cast<lldb::offset_t>(index) * index_size;
return llvm::object::SectionedAddress{
m_dwarf.GetDWARFContext().getOrLoadAddrData().GetMaxU64(
&offset, index_size)};
// }
offset_t offset = 0;
- int i = 0;
+ uint64_t i = 0;
uint32_t version = extractor.GetU32(&offset);
if (version == 1) {
pending_item_refs.new_style = true;
uint32_t item_size = extractor.GetU32(&offset);
uint32_t start_of_array_offset = offset;
while (offset < pending_items_pointer.items_buffer_size &&
- static_cast<size_t>(i) < pending_items_pointer.count) {
+ i < pending_items_pointer.count) {
offset = start_of_array_offset + (i * item_size);
ItemRefAndCodeAddress item;
item.item_ref = extractor.GetAddress(&offset);
offset = 0;
pending_item_refs.new_style = false;
while (offset < pending_items_pointer.items_buffer_size &&
- static_cast<size_t>(i) < pending_items_pointer.count) {
+ i < pending_items_pointer.count) {
ItemRefAndCodeAddress item;
item.item_ref = extractor.GetAddress(&offset);
item.code_address = LLDB_INVALID_ADDRESS;
// path jumps over the mid-function epilogue
UnwindPlan::RowSP prologue_completed_row; // copy of prologue row of CFI
- int prologue_completed_sp_bytes_offset_from_cfa; // The sp value before the
+ int prologue_completed_sp_bytes_offset_from_cfa = 0; // The sp value before the
// epilogue started executed
bool prologue_completed_is_aligned = false;
std::vector<bool> prologue_completed_saved_registers;