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

@@ -31,9 +31,11 @@ void sym_AddSymbol(Symbol &symbol) {
}
Symbol *other = sym_GetSymbol(symbol.name);
int32_t *symValue = symbol.data.holds<int32_t>() ? &symbol.data.get<int32_t>() : nullptr;
int32_t *otherValue =
other && other->data.holds<int32_t>() ? &other->data.get<int32_t>() : nullptr;
int32_t *symValue =
std::holds_alternative<int32_t>(symbol.data) ? &std::get<int32_t>(symbol.data) : nullptr;
int32_t *otherValue = other && std::holds_alternative<int32_t>(other->data)
? &std::get<int32_t>(other->data)
: nullptr;
// Check if the symbol already exists with a different value
if (other && !(symValue && otherValue && *symValue == *otherValue)) {
@@ -85,7 +87,7 @@ void sym_DumpLocalAliasedSymbols(std::string const &name) {
fprintf(
stderr,
" A %s with that name is defined but not exported at ",
local->data.holds<Label>() ? "label" : "constant"
std::holds_alternative<Label>(local->data) ? "label" : "constant"
);
assume(local->src);
local->src->dump(local->lineNo);