[llvm] r192298 - Add a GlobalAlias::isValidLinkage to reduce code duplication.
Rafael Espindola
rafael.espindola at gmail.com
Wed Oct 9 09:07:32 PDT 2013
Author: rafael
Date: Wed Oct 9 11:07:32 2013
New Revision: 192298
URL: http://llvm.org/viewvc/llvm-project?rev=192298&view=rev
Log:
Add a GlobalAlias::isValidLinkage to reduce code duplication.
Thanks to Reid Kleckner for the suggestion.
Modified:
llvm/trunk/include/llvm/IR/GlobalAlias.h
llvm/trunk/lib/AsmParser/LLParser.cpp
llvm/trunk/lib/IR/Verifier.cpp
Modified: llvm/trunk/include/llvm/IR/GlobalAlias.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/GlobalAlias.h?rev=192298&r1=192297&r2=192298&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/GlobalAlias.h (original)
+++ llvm/trunk/include/llvm/IR/GlobalAlias.h Wed Oct 9 11:07:32 2013
@@ -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;
Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=192298&r1=192297&r2=192298&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Wed Oct 9 11:07:32 2013
@@ -634,10 +634,7 @@ bool LLParser::ParseAlias(const std::str
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;
Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=192298&r1=192297&r2=192298&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Wed Oct 9 11:07:32 2013
@@ -529,8 +529,7 @@ void Verifier::visitGlobalVariable(Globa
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);
More information about the llvm-commits
mailing list