Ensure that BitTableAccessor refers to non-null table.
Hopefully this should make clang analyzer happy.
Test: test-art-host-gtest-stack_map_test
Change-Id: I19c9048302dd47dd262842e0b58ed139f83fa1f6
diff --git a/libartbase/base/bit_table.h b/libartbase/base/bit_table.h
index 8036db1..ef2cf21 100644
--- a/libartbase/base/bit_table.h
+++ b/libartbase/base/bit_table.h
@@ -139,14 +139,14 @@
static constexpr uint32_t kNumColumns = NumColumns;
static constexpr uint32_t kNoValue = BitTableBase<kNumColumns>::kNoValue;
- BitTableAccessor() {}
BitTableAccessor(const BitTableBase<kNumColumns>* table, uint32_t row)
: table_(table), row_(row) {
+ DCHECK(table_ != nullptr);
}
ALWAYS_INLINE uint32_t Row() const { return row_; }
- ALWAYS_INLINE bool IsValid() const { return table_ != nullptr && row_ < table_->NumRows(); }
+ ALWAYS_INLINE bool IsValid() const { return row_ < table_->NumRows(); }
ALWAYS_INLINE bool Equals(const BitTableAccessor& other) {
return this->table_ == other.table_ && this->row_ == other.row_;
@@ -228,6 +228,10 @@
ALWAYS_INLINE Accessor GetRow(uint32_t row) const {
return Accessor(this, row);
}
+
+ ALWAYS_INLINE Accessor GetInvalidRow() const {
+ return Accessor(this, static_cast<uint32_t>(-1));
+ }
};
template<typename Accessor>
diff --git a/runtime/stack_map.cc b/runtime/stack_map.cc
index f40168b..5472d4c 100644
--- a/runtime/stack_map.cc
+++ b/runtime/stack_map.cc
@@ -44,7 +44,7 @@
return *it;
}
}
- return StackMap();
+ return stack_maps_.GetInvalidRow();
}
// Scan backward to determine dex register locations at given stack map.
diff --git a/runtime/stack_map.h b/runtime/stack_map.h
index 7aac792..c17efcf 100644
--- a/runtime/stack_map.h
+++ b/runtime/stack_map.h
@@ -388,7 +388,7 @@
return stack_map;
}
}
- return StackMap();
+ return stack_maps_.GetInvalidRow();
}
// Searches the stack map list backwards because catch stack maps are stored at the end.
@@ -399,7 +399,7 @@
return stack_map;
}
}
- return StackMap();
+ return stack_maps_.GetInvalidRow();
}
StackMap GetOsrStackMapForDexPc(uint32_t dex_pc) const {
@@ -409,7 +409,7 @@
return stack_map;
}
}
- return StackMap();
+ return stack_maps_.GetInvalidRow();
}
StackMap GetStackMapForNativePcOffset(uint32_t pc, InstructionSet isa = kRuntimeISA) const;
@@ -421,7 +421,7 @@
return item;
}
}
- return InvokeInfo();
+ return invoke_infos_.GetInvalidRow();
}
// Dump this CodeInfo object on `vios`.