aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-10-09 16:07:32 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-10-09 16:07:32 +0000
commit1a525e8c80305777e3ca0cba0e1903fdbf04aa86 (patch)
tree439b7b96f5f46b5fca34443f3f730ad608b8dfce
parent3b73dea538d9c53e205d38bfbcf99dd64306874b (diff)
downloadexternal_llvm-1a525e8c80305777e3ca0cba0e1903fdbf04aa86.zip
external_llvm-1a525e8c80305777e3ca0cba0e1903fdbf04aa86.tar.gz
external_llvm-1a525e8c80305777e3ca0cba0e1903fdbf04aa86.tar.bz2
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
-rw-r--r--include/llvm/IR/GlobalAlias.h5
-rw-r--r--lib/AsmParser/LLParser.cpp5
-rw-r--r--lib/IR/Verifier.cpp3
3 files changed, 7 insertions, 6 deletions
diff --git a/include/llvm/IR/GlobalAlias.h b/include/llvm/IR/GlobalAlias.h
index e09fb6a..fec61a7 100644
--- a/include/llvm/IR/GlobalAlias.h
+++ b/include/llvm/IR/GlobalAlias.h
@@ -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;
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index d5c5db1..74c0ea4 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -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;
diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp
index c010839..c7559c1 100644
--- a/lib/IR/Verifier.cpp
+++ b/lib/IR/Verifier.cpp
@@ -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);