mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-14 15:46:32 +00:00
[MC] Remove SetUsed on isUndefined and getFragment
Due to the known limitations of .set reassignment (see https://sourceware.org/PR288), we use diagnostics to reject patterns that could lead to errors (ae7ac010594f693fdf7b3ab879e196428d961e75 2009-06)). This code gets refined multiple times, see: * 9b4a824217f1fe23f83045afe7521acb791bc2d0 (2010-05) `IsUsedInExpr` * 46c79ef1132607aead144dfda0f26aa8b065214f (2010-11) renamed `IsUsedInExpr` to `IsUsed` The related `SetUsed` bit seems unnecessary nowadays.
This commit is contained in:
parent
1c5ce2d74f
commit
ca5b3a0f51
@ -257,9 +257,7 @@ public:
|
||||
}
|
||||
|
||||
/// isUndefined - Check if this symbol undefined (i.e., implicitly defined).
|
||||
bool isUndefined(bool SetUsed = true) const {
|
||||
return getFragment(SetUsed) == nullptr;
|
||||
}
|
||||
bool isUndefined() const { return getFragment() == nullptr; }
|
||||
|
||||
/// isAbsolute - Check if this is an absolute symbol.
|
||||
bool isAbsolute() const {
|
||||
@ -395,7 +393,7 @@ public:
|
||||
return SymbolContents == SymContentsTargetCommon;
|
||||
}
|
||||
|
||||
MCFragment *getFragment(bool SetUsed = true) const {
|
||||
MCFragment *getFragment(bool SetUsed = false) const {
|
||||
if (Fragment || !isVariable() || isWeakExternal())
|
||||
return Fragment;
|
||||
// If the symbol is a non-weak alias, get information about
|
||||
|
@ -5284,9 +5284,9 @@ bool AsmParser::parseDirectiveIfdef(SMLoc DirectiveLoc, bool expect_defined) {
|
||||
MCSymbol *Sym = getContext().lookupSymbol(Name);
|
||||
|
||||
if (expect_defined)
|
||||
TheCondState.CondMet = (Sym && !Sym->isUndefined(false));
|
||||
TheCondState.CondMet = (Sym && !Sym->isUndefined());
|
||||
else
|
||||
TheCondState.CondMet = (!Sym || Sym->isUndefined(false));
|
||||
TheCondState.CondMet = (!Sym || Sym->isUndefined());
|
||||
TheCondState.Ignore = !TheCondState.CondMet;
|
||||
}
|
||||
|
||||
@ -6362,8 +6362,7 @@ bool parseAssignmentExpression(StringRef Name, bool allow_redef,
|
||||
// FIXME: Diagnose assignment to protected identifier (e.g., register name).
|
||||
if (Value->isSymbolUsedInExpression(Sym))
|
||||
return Parser.Error(EqualLoc, "Recursive use of '" + Name + "'");
|
||||
else if (Sym->isUndefined(/*SetUsed*/ false) && !Sym->isUsed() &&
|
||||
!Sym->isVariable())
|
||||
else if (Sym->isUndefined() && !Sym->isUsed() && !Sym->isVariable())
|
||||
; // Allow redefinitions of undefined symbols only used in directives.
|
||||
else if (Sym->isVariable() && !Sym->isUsed() && allow_redef)
|
||||
; // Allow redefinitions of variables that haven't yet been used.
|
||||
|
@ -4761,7 +4761,7 @@ bool MasmParser::parseDirectiveIfdef(SMLoc DirectiveLoc, bool expect_defined) {
|
||||
is_defined = true;
|
||||
} else {
|
||||
MCSymbol *Sym = getContext().lookupSymbol(Name.lower());
|
||||
is_defined = (Sym && !Sym->isUndefined(false));
|
||||
is_defined = (Sym && !Sym->isUndefined());
|
||||
}
|
||||
}
|
||||
|
||||
@ -4882,7 +4882,7 @@ bool MasmParser::parseDirectiveElseIfdef(SMLoc DirectiveLoc,
|
||||
is_defined = true;
|
||||
} else {
|
||||
MCSymbol *Sym = getContext().lookupSymbol(Name);
|
||||
is_defined = (Sym && !Sym->isUndefined(false));
|
||||
is_defined = (Sym && !Sym->isUndefined());
|
||||
}
|
||||
}
|
||||
|
||||
@ -5052,7 +5052,7 @@ bool MasmParser::parseDirectiveErrorIfdef(SMLoc DirectiveLoc,
|
||||
IsDefined = true;
|
||||
} else {
|
||||
MCSymbol *Sym = getContext().lookupSymbol(Name);
|
||||
IsDefined = (Sym && !Sym->isUndefined(false));
|
||||
IsDefined = (Sym && !Sym->isUndefined());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user