1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

Add a GlobalAlias::isValidLinkage to reduce code duplication.

Thanks to Reid Kleckner for the suggestion.

llvm-svn: 192298
This commit is contained in:
Rafael Espindola 2013-10-09 16:07:32 +00:00
parent aedc12be2e
commit f0991565b5
3 changed files with 7 additions and 6 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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);