Replace Either with std::variant (#1731)

This commit is contained in:
Rangi
2025-07-08 13:59:03 -04:00
committed by GitHub
parent 35962dedc4
commit fda54fd0c3
17 changed files with 94 additions and 271 deletions

View File

@@ -418,11 +418,11 @@ void sdobj_ReadFile(FileStackNode const &where, FILE *file, std::vector<Symbol>
// The same symbol can only be defined twice if neither
// definition is in a floating section
auto checkSymbol = [](Symbol const &sym) -> std::tuple<Section *, int32_t> {
if (sym.data.holds<Label>()) {
Label const &label = sym.data.get<Label>();
if (std::holds_alternative<Label>(sym.data)) {
Label const &label = std::get<Label>(sym.data);
return {label.section, label.offset};
}
return {nullptr, sym.data.get<int32_t>()};
return {nullptr, std::get<int32_t>(sym.data)};
};
auto [symbolSection, symbolValue] = checkSymbol(symbol);
auto [otherSection, otherValue] = checkSymbol(*other);
@@ -929,8 +929,8 @@ void sdobj_ReadFile(FileStackNode const &where, FILE *file, std::vector<Symbol>
// This has to run **after** all the `sect_AddSection()` calls,
// so that `sect_GetSection()` will work
for (Symbol &sym : fileSymbols) {
if (sym.data.holds<Label>()) {
Label &label = sym.data.get<Label>();
if (std::holds_alternative<Label>(sym.data)) {
Label &label = std::get<Label>(sym.data);
if (Section *section = label.section; section->modifier != SECTION_NORMAL) {
if (section->modifier == SECTION_FRAGMENT) {
// Add the fragment's offset to the symbol's