[MCDisassembler] Reorder XCOFF specific constructor parameters. NFC

to prevent overload resolution confusion. In particular, if we add
another parameter to the generic constructor, MCDisassemblerTest.cpp
specified constructors will be resolve to the generic constructor, which
is unintended.
This commit is contained in:
Fangrui Song 2023-07-27 19:59:26 -07:00
parent 845d83d85f
commit e09a1b51ab
3 changed files with 10 additions and 12 deletions

View File

@ -37,9 +37,8 @@ private:
bool HasType;
public:
SymbolInfoTy(uint64_t Addr, StringRef Name,
std::optional<XCOFF::StorageMappingClass> Smc,
std::optional<uint32_t> Idx, bool Label)
SymbolInfoTy(std::optional<XCOFF::StorageMappingClass> Smc, uint64_t Addr,
StringRef Name, std::optional<uint32_t> Idx, bool Label)
: Addr(Addr), Name(Name), XCOFFSymInfo{Smc, Idx, Label}, Type(0),
IsXCOFF(true), HasType(false) {}
SymbolInfoTy(uint64_t Addr, StringRef Name, uint8_t Type,

View File

@ -1210,7 +1210,7 @@ SymbolInfoTy objdump::createSymbolInfo(const ObjectFile &Obj,
const uint32_t SymbolIndex = XCOFFObj.getSymbolIndex(SymbolDRI.p);
std::optional<XCOFF::StorageMappingClass> Smc =
getXCOFFSymbolCsectSMC(XCOFFObj, Symbol);
return SymbolInfoTy(Addr, Name, Smc, SymbolIndex,
return SymbolInfoTy(Smc, Addr, Name, SymbolIndex,
isLabel(XCOFFObj, Symbol));
} else if (Obj.isXCOFF()) {
const SymbolRef::Type SymType = unwrapOrError(Symbol.getType(), FileName);
@ -1225,7 +1225,7 @@ static SymbolInfoTy createDummySymbolInfo(const ObjectFile &Obj,
const uint64_t Addr, StringRef &Name,
uint8_t Type) {
if (Obj.isXCOFF() && (SymbolDescription || TracebackTable))
return SymbolInfoTy(Addr, Name, std::nullopt, std::nullopt, false);
return SymbolInfoTy(std::nullopt, Addr, Name, std::nullopt, false);
else
return SymbolInfoTy(Addr, Name, Type);
}

View File

@ -12,13 +12,12 @@
using namespace llvm;
TEST(MCDisassembler, XCOFFSymbolPriorityTest) {
SymbolInfoTy SIT1(0x100000, "sym1", std::nullopt, 1, false);
SymbolInfoTy SIT2(0x110000, "sym2", std::nullopt, 2, false);
SymbolInfoTy SIT3(0x120000, ".func", XCOFF::XMC_PR, 3, true);
SymbolInfoTy SIT4(0x120000, ".text", XCOFF::XMC_PR, 4, false);
SymbolInfoTy SIT5(0x130000, "TOC", XCOFF::XMC_TC0, 5, false);
SymbolInfoTy SIT6(0x130000, "func", XCOFF::XMC_TC, 6, false);
SymbolInfoTy SIT1(std::nullopt, 0x100000, "sym1", 1, false);
SymbolInfoTy SIT2(std::nullopt, 0x110000, "sym2", 2, false);
SymbolInfoTy SIT3(XCOFF::XMC_PR, 0x120000, ".func", 3, true);
SymbolInfoTy SIT4(XCOFF::XMC_PR, 0x120000, ".text", 4, false);
SymbolInfoTy SIT5(XCOFF::XMC_TC0, 0x130000, "TOC", 5, false);
SymbolInfoTy SIT6(XCOFF::XMC_TC, 0x130000, "func", 6, false);
// Test that higher addresses would appear later than lower ones when symbols
// are sorted in ascending order.