Change RegsTmpl to RegsImpl.
Also clang-format modified Regs.cpp slightly.
Bug: 23762183
Test: Built and ran unit tests.
Change-Id: I1c7c1b01974ee3f35059c42b8e2aef24d46c81a7
diff --git a/libunwindstack/DwarfOp.h b/libunwindstack/DwarfOp.h
index ed6537a..0f4b36d 100644
--- a/libunwindstack/DwarfOp.h
+++ b/libunwindstack/DwarfOp.h
@@ -37,7 +37,7 @@
class DwarfMemory;
class Memory;
template <typename AddressType>
-class RegsTmpl;
+class RegsImpl;
template <typename AddressType>
class DwarfOp {
@@ -67,7 +67,7 @@
AddressType StackAt(size_t index) { return stack_[index]; }
size_t StackSize() { return stack_.size(); }
- void set_regs(RegsTmpl<AddressType>* regs) { regs_ = regs; }
+ void set_regs(RegsImpl<AddressType>* regs) { regs_ = regs; }
DwarfError last_error() { return last_error_; }
@@ -91,7 +91,7 @@
DwarfMemory* memory_;
Memory* regular_memory_;
- RegsTmpl<AddressType>* regs_;
+ RegsImpl<AddressType>* regs_;
bool is_register_ = false;
DwarfError last_error_ = DWARF_ERROR_NONE;
uint8_t cur_op_;
diff --git a/libunwindstack/DwarfSection.cpp b/libunwindstack/DwarfSection.cpp
index 0148ffb..4c98aa3 100644
--- a/libunwindstack/DwarfSection.cpp
+++ b/libunwindstack/DwarfSection.cpp
@@ -86,7 +86,7 @@
template <typename AddressType>
bool DwarfSectionImpl<AddressType>::Eval(const DwarfCie* cie, Memory* regular_memory,
const dwarf_loc_regs_t& loc_regs, Regs* regs) {
- RegsTmpl<AddressType>* cur_regs = reinterpret_cast<RegsTmpl<AddressType>*>(regs);
+ RegsImpl<AddressType>* cur_regs = reinterpret_cast<RegsImpl<AddressType>*>(regs);
if (cie->return_address_register >= cur_regs->total_regs()) {
last_error_ = DWARF_ERROR_ILLEGAL_VALUE;
return false;
diff --git a/libunwindstack/Regs.cpp b/libunwindstack/Regs.cpp
index adb6522..e7d10b2 100644
--- a/libunwindstack/Regs.cpp
+++ b/libunwindstack/Regs.cpp
@@ -30,7 +30,7 @@
#include "User.h"
template <typename AddressType>
-uint64_t RegsTmpl<AddressType>::GetRelPc(Elf* elf, const MapInfo* map_info) {
+uint64_t RegsImpl<AddressType>::GetRelPc(Elf* elf, const MapInfo* map_info) {
uint64_t load_bias = 0;
if (elf->valid()) {
load_bias = elf->interface()->load_bias();
@@ -40,7 +40,7 @@
}
template <typename AddressType>
-bool RegsTmpl<AddressType>::GetReturnAddressFromDefault(Memory* memory, uint64_t* value) {
+bool RegsImpl<AddressType>::GetReturnAddressFromDefault(Memory* memory, uint64_t* value) {
switch (return_loc_.type) {
case LOCATION_REGISTER:
assert(return_loc_.value < total_regs_);
@@ -59,9 +59,8 @@
}
}
-RegsArm::RegsArm() : RegsTmpl<uint32_t>(ARM_REG_LAST, ARM_REG_SP,
- Location(LOCATION_REGISTER, ARM_REG_LR)) {
-}
+RegsArm::RegsArm()
+ : RegsImpl<uint32_t>(ARM_REG_LAST, ARM_REG_SP, Location(LOCATION_REGISTER, ARM_REG_LR)) {}
uint64_t RegsArm::GetAdjustedPc(uint64_t rel_pc, Elf* elf) {
if (!elf->valid()) {
@@ -89,9 +88,8 @@
return rel_pc - 4;
}
-RegsArm64::RegsArm64() : RegsTmpl<uint64_t>(ARM64_REG_LAST, ARM64_REG_SP,
- Location(LOCATION_REGISTER, ARM64_REG_LR)) {
-}
+RegsArm64::RegsArm64()
+ : RegsImpl<uint64_t>(ARM64_REG_LAST, ARM64_REG_SP, Location(LOCATION_REGISTER, ARM64_REG_LR)) {}
uint64_t RegsArm64::GetAdjustedPc(uint64_t rel_pc, Elf* elf) {
if (!elf->valid()) {
@@ -104,9 +102,8 @@
return rel_pc - 4;
}
-RegsX86::RegsX86() : RegsTmpl<uint32_t>(X86_REG_LAST, X86_REG_SP,
- Location(LOCATION_SP_OFFSET, -4)) {
-}
+RegsX86::RegsX86()
+ : RegsImpl<uint32_t>(X86_REG_LAST, X86_REG_SP, Location(LOCATION_SP_OFFSET, -4)) {}
uint64_t RegsX86::GetAdjustedPc(uint64_t rel_pc, Elf* elf) {
if (!elf->valid()) {
@@ -119,9 +116,8 @@
return rel_pc - 1;
}
-RegsX86_64::RegsX86_64() : RegsTmpl<uint64_t>(X86_64_REG_LAST, X86_64_REG_SP,
- Location(LOCATION_SP_OFFSET, -8)) {
-}
+RegsX86_64::RegsX86_64()
+ : RegsImpl<uint64_t>(X86_64_REG_LAST, X86_64_REG_SP, Location(LOCATION_SP_OFFSET, -8)) {}
uint64_t RegsX86_64::GetAdjustedPc(uint64_t rel_pc, Elf* elf) {
if (!elf->valid()) {
diff --git a/libunwindstack/Regs.h b/libunwindstack/Regs.h
index 718fc85..8f5a721 100644
--- a/libunwindstack/Regs.h
+++ b/libunwindstack/Regs.h
@@ -66,11 +66,11 @@
};
template <typename AddressType>
-class RegsTmpl : public Regs {
+class RegsImpl : public Regs {
public:
- RegsTmpl(uint16_t total_regs, uint16_t sp_reg, Location return_loc)
+ RegsImpl(uint16_t total_regs, uint16_t sp_reg, Location return_loc)
: Regs(total_regs, sp_reg, return_loc), regs_(total_regs) {}
- virtual ~RegsTmpl() = default;
+ virtual ~RegsImpl() = default;
uint64_t GetRelPc(Elf* elf, const MapInfo* map_info) override;
@@ -92,7 +92,7 @@
std::vector<AddressType> regs_;
};
-class RegsArm : public RegsTmpl<uint32_t> {
+class RegsArm : public RegsImpl<uint32_t> {
public:
RegsArm();
virtual ~RegsArm() = default;
@@ -100,7 +100,7 @@
uint64_t GetAdjustedPc(uint64_t rel_pc, Elf* elf) override;
};
-class RegsArm64 : public RegsTmpl<uint64_t> {
+class RegsArm64 : public RegsImpl<uint64_t> {
public:
RegsArm64();
virtual ~RegsArm64() = default;
@@ -108,7 +108,7 @@
uint64_t GetAdjustedPc(uint64_t rel_pc, Elf* elf) override;
};
-class RegsX86 : public RegsTmpl<uint32_t> {
+class RegsX86 : public RegsImpl<uint32_t> {
public:
RegsX86();
virtual ~RegsX86() = default;
@@ -116,7 +116,7 @@
uint64_t GetAdjustedPc(uint64_t rel_pc, Elf* elf) override;
};
-class RegsX86_64 : public RegsTmpl<uint64_t> {
+class RegsX86_64 : public RegsImpl<uint64_t> {
public:
RegsX86_64();
virtual ~RegsX86_64() = default;
diff --git a/libunwindstack/tests/RegsFake.h b/libunwindstack/tests/RegsFake.h
index dbc06a4..ff030c8 100644
--- a/libunwindstack/tests/RegsFake.h
+++ b/libunwindstack/tests/RegsFake.h
@@ -22,10 +22,10 @@
#include "Regs.h"
template <typename TypeParam>
-class RegsFake : public RegsTmpl<TypeParam> {
+class RegsFake : public RegsImpl<TypeParam> {
public:
RegsFake(uint16_t total_regs, uint16_t sp_reg)
- : RegsTmpl<TypeParam>(total_regs, sp_reg, Regs::Location(Regs::LOCATION_UNKNOWN, 0)) {}
+ : RegsImpl<TypeParam>(total_regs, sp_reg, Regs::Location(Regs::LOCATION_UNKNOWN, 0)) {}
virtual ~RegsFake() = default;
uint64_t GetRelPc(Elf*, const MapInfo*) override { return 0; }
diff --git a/libunwindstack/tests/RegsTest.cpp b/libunwindstack/tests/RegsTest.cpp
index 0dac278..3056373 100644
--- a/libunwindstack/tests/RegsTest.cpp
+++ b/libunwindstack/tests/RegsTest.cpp
@@ -48,13 +48,13 @@
};
template <typename TypeParam>
-class RegsTestTmpl : public RegsTmpl<TypeParam> {
+class RegsTestImpl : public RegsImpl<TypeParam> {
public:
- RegsTestTmpl(uint16_t total_regs, uint16_t regs_sp)
- : RegsTmpl<TypeParam>(total_regs, regs_sp, Regs::Location(Regs::LOCATION_UNKNOWN, 0)) {}
- RegsTestTmpl(uint16_t total_regs, uint16_t regs_sp, Regs::Location return_loc)
- : RegsTmpl<TypeParam>(total_regs, regs_sp, return_loc) {}
- virtual ~RegsTestTmpl() = default;
+ RegsTestImpl(uint16_t total_regs, uint16_t regs_sp)
+ : RegsImpl<TypeParam>(total_regs, regs_sp, Regs::Location(Regs::LOCATION_UNKNOWN, 0)) {}
+ RegsTestImpl(uint16_t total_regs, uint16_t regs_sp, Regs::Location return_loc)
+ : RegsImpl<TypeParam>(total_regs, regs_sp, return_loc) {}
+ virtual ~RegsTestImpl() = default;
uint64_t GetAdjustedPc(uint64_t, Elf*) { return 0; }
};
@@ -80,7 +80,7 @@
};
TEST_F(RegsTest, regs32) {
- RegsTestTmpl<uint32_t> regs32(50, 10);
+ RegsTestImpl<uint32_t> regs32(50, 10);
ASSERT_EQ(50U, regs32.total_regs());
ASSERT_EQ(10U, regs32.sp_reg());
@@ -103,7 +103,7 @@
}
TEST_F(RegsTest, regs64) {
- RegsTestTmpl<uint64_t> regs64(30, 12);
+ RegsTestImpl<uint64_t> regs64(30, 12);
ASSERT_EQ(30U, regs64.total_regs());
ASSERT_EQ(12U, regs64.sp_reg());
@@ -127,7 +127,7 @@
template <typename AddressType>
void RegsTest::regs_rel_pc() {
- RegsTestTmpl<AddressType> regs(30, 12);
+ RegsTestImpl<AddressType> regs(30, 12);
elf_interface_->set_load_bias(0);
MapInfo map_info{.start = 0x1000, .end = 0x2000};
@@ -147,7 +147,7 @@
template <typename AddressType>
void RegsTest::regs_return_address_register() {
- RegsTestTmpl<AddressType> regs(20, 10, Regs::Location(Regs::LOCATION_REGISTER, 5));
+ RegsTestImpl<AddressType> regs(20, 10, Regs::Location(Regs::LOCATION_REGISTER, 5));
regs[5] = 0x12345;
uint64_t value;
@@ -164,7 +164,7 @@
}
TEST_F(RegsTest, regs32_return_address_sp_offset) {
- RegsTestTmpl<uint32_t> regs(20, 10, Regs::Location(Regs::LOCATION_SP_OFFSET, -2));
+ RegsTestImpl<uint32_t> regs(20, 10, Regs::Location(Regs::LOCATION_SP_OFFSET, -2));
regs.set_sp(0x2002);
memory_->SetData32(0x2000, 0x12345678);
@@ -174,7 +174,7 @@
}
TEST_F(RegsTest, regs64_return_address_sp_offset) {
- RegsTestTmpl<uint64_t> regs(20, 10, Regs::Location(Regs::LOCATION_SP_OFFSET, -8));
+ RegsTestImpl<uint64_t> regs(20, 10, Regs::Location(Regs::LOCATION_SP_OFFSET, -8));
regs.set_sp(0x2008);
memory_->SetData64(0x2000, 0x12345678aabbccddULL);