mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Add a GlobalAlias::isValidLinkage to reduce code duplication.
Thanks to Reid Kleckner for the suggestion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192298 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3b73dea538
commit
1a525e8c80
@ -81,6 +81,11 @@ public:
|
||||
return const_cast<GlobalAlias *>(this)->resolveAliasedGlobal(stopOnWeak);
|
||||
}
|
||||
|
||||
static bool isValidLinkage(LinkageTypes L) {
|
||||
return isExternalLinkage(L) || isLocalLinkage(L) ||
|
||||
isWeakLinkage(L) || isLinkOnceLinkage(L);
|
||||
}
|
||||
|
||||
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||
static inline bool classof(const Value *V) {
|
||||
return V->getValueID() == Value::GlobalAliasVal;
|
||||
|
@ -634,10 +634,7 @@ bool LLParser::ParseAlias(const std::string &Name, LocTy NameLoc,
|
||||
|
||||
GlobalValue::LinkageTypes Linkage = (GlobalValue::LinkageTypes) L;
|
||||
|
||||
if(!GlobalValue::isExternalLinkage(Linkage) &&
|
||||
!GlobalValue::isLocalLinkage(Linkage) &&
|
||||
!GlobalValue::isWeakLinkage(Linkage) &&
|
||||
!GlobalValue::isLinkOnceLinkage(Linkage))
|
||||
if(!GlobalAlias::isValidLinkage(Linkage))
|
||||
return Error(LinkageLoc, "invalid linkage type for alias");
|
||||
|
||||
Constant *Aliasee;
|
||||
|
@ -529,8 +529,7 @@ void Verifier::visitGlobalVariable(GlobalVariable &GV) {
|
||||
void Verifier::visitGlobalAlias(GlobalAlias &GA) {
|
||||
Assert1(!GA.getName().empty(),
|
||||
"Alias name cannot be empty!", &GA);
|
||||
Assert1(GA.hasExternalLinkage() || GA.hasLocalLinkage() ||
|
||||
GA.hasWeakLinkage() || GA.hasLinkOnceLinkage(),
|
||||
Assert1(GlobalAlias::isValidLinkage(GA.getLinkage()),
|
||||
"Alias should have external or external weak linkage!", &GA);
|
||||
Assert1(GA.getAliasee(),
|
||||
"Aliasee cannot be NULL!", &GA);
|
||||
|
Loading…
Reference in New Issue
Block a user