diff --git a/llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h b/llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h index 55cba3c3bae963..fc2d22eee8dfc6 100644 --- a/llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h +++ b/llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h @@ -19,24 +19,19 @@ namespace llvm { -struct XCOFFSymbolInfo { +struct XCOFFSymbolInfoTy { std::optional StorageMappingClass; std::optional Index; - bool IsLabel; - XCOFFSymbolInfo(std::optional Smc, - std::optional Idx, bool Label) - : StorageMappingClass(Smc), Index(Idx), IsLabel(Label) {} - - bool operator<(const XCOFFSymbolInfo &SymInfo) const; + bool IsLabel = false; + bool operator<(const XCOFFSymbolInfoTy &SymInfo) const; }; struct SymbolInfoTy { uint64_t Addr; StringRef Name; - union { - uint8_t Type; - XCOFFSymbolInfo XCOFFSymInfo; - }; + // XCOFF uses XCOFFSymInfo. Other targets use Type. + XCOFFSymbolInfoTy XCOFFSymInfo; + uint8_t Type; private: bool IsXCOFF; @@ -46,8 +41,8 @@ struct SymbolInfoTy { SymbolInfoTy(uint64_t Addr, StringRef Name, std::optional Smc, std::optional Idx, bool Label) - : Addr(Addr), Name(Name), XCOFFSymInfo(Smc, Idx, Label), IsXCOFF(true), - HasType(false) {} + : Addr(Addr), Name(Name), XCOFFSymInfo{Smc, Idx, Label}, Type(0), + IsXCOFF(true), HasType(false) {} SymbolInfoTy(uint64_t Addr, StringRef Name, uint8_t Type, bool IsXCOFF = false) : Addr(Addr), Name(Name), Type(Type), IsXCOFF(IsXCOFF), HasType(true) {} diff --git a/llvm/lib/MC/MCDisassembler/MCDisassembler.cpp b/llvm/lib/MC/MCDisassembler/MCDisassembler.cpp index e3a0848009770b..6d7f6ed48ea00b 100644 --- a/llvm/lib/MC/MCDisassembler/MCDisassembler.cpp +++ b/llvm/lib/MC/MCDisassembler/MCDisassembler.cpp @@ -82,7 +82,7 @@ static uint8_t getSMCPriority(XCOFF::StorageMappingClass SMC) { /// The symbols in the same section are sorted in ascending order. /// llvm-objdump -D will choose the highest priority symbol to display when /// there are symbols with the same address. -bool XCOFFSymbolInfo::operator<(const XCOFFSymbolInfo &SymInfo) const { +bool XCOFFSymbolInfoTy::operator<(const XCOFFSymbolInfoTy &SymInfo) const { // Label symbols have higher priority than non-label symbols. if (IsLabel != SymInfo.IsLabel) return SymInfo.IsLabel;