llvm.org GIT mirror llvm / 1a525e8
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 Rafael Espindola 6 years ago
3 changed file(s) with 7 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
8080 return const_cast(this)->resolveAliasedGlobal(stopOnWeak);
8181 }
8282
83 static bool isValidLinkage(LinkageTypes L) {
84 return isExternalLinkage(L) || isLocalLinkage(L) ||
85 isWeakLinkage(L) || isLinkOnceLinkage(L);
86 }
87
8388 // Methods for support type inquiry through isa, cast, and dyn_cast:
8489 static inline bool classof(const Value *V) {
8590 return V->getValueID() == Value::GlobalAliasVal;
633633
634634 GlobalValue::LinkageTypes Linkage = (GlobalValue::LinkageTypes) L;
635635
636 if(!GlobalValue::isExternalLinkage(Linkage) &&
637 !GlobalValue::isLocalLinkage(Linkage) &&
638 !GlobalValue::isWeakLinkage(Linkage) &&
639 !GlobalValue::isLinkOnceLinkage(Linkage))
636 if(!GlobalAlias::isValidLinkage(Linkage))
640637 return Error(LinkageLoc, "invalid linkage type for alias");
641638
642639 Constant *Aliasee;
528528 void Verifier::visitGlobalAlias(GlobalAlias &GA) {
529529 Assert1(!GA.getName().empty(),
530530 "Alias name cannot be empty!", &GA);
531 Assert1(GA.hasExternalLinkage() || GA.hasLocalLinkage() ||
532 GA.hasWeakLinkage() || GA.hasLinkOnceLinkage(),
531 Assert1(GlobalAlias::isValidLinkage(GA.getLinkage()),
533532 "Alias should have external or external weak linkage!", &GA);
534533 Assert1(GA.getAliasee(),
535534 "Aliasee cannot be NULL!", &GA);