[llvm] r269184 - Refactor duplicated check for valid declaration linkage. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed May 11 06:51:39 PDT 2016
Author: rafael
Date: Wed May 11 08:51:39 2016
New Revision: 269184
URL: http://llvm.org/viewvc/llvm-project?rev=269184&view=rev
Log:
Refactor duplicated check for valid declaration linkage. NFC.
Modified:
llvm/trunk/include/llvm/IR/GlobalValue.h
llvm/trunk/lib/AsmParser/LLParser.cpp
llvm/trunk/lib/IR/Verifier.cpp
Modified: llvm/trunk/include/llvm/IR/GlobalValue.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/GlobalValue.h?rev=269184&r1=269183&r2=269184&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/GlobalValue.h (original)
+++ llvm/trunk/include/llvm/IR/GlobalValue.h Wed May 11 08:51:39 2016
@@ -258,6 +258,9 @@ public:
static bool isCommonLinkage(LinkageTypes Linkage) {
return Linkage == CommonLinkage;
}
+ static bool isValidDeclarationLinkage(LinkageTypes Linkage) {
+ return isExternalWeakLinkage(Linkage) || isExternalLinkage(Linkage);
+ }
/// Whether the definition of this global may be replaced by something
/// non-equivalent at link time. For example, if a function has weak linkage
@@ -366,6 +369,9 @@ public:
return isExternalWeakLinkage(getLinkage());
}
bool hasCommonLinkage() const { return isCommonLinkage(getLinkage()); }
+ bool hasValidDeclarationLinkage() const {
+ return isValidDeclarationLinkage(getLinkage());
+ }
void setLinkage(LinkageTypes LT) {
if (isLocalLinkage(LT))
Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=269184&r1=269183&r2=269184&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Wed May 11 08:51:39 2016
@@ -825,8 +825,9 @@ bool LLParser::ParseGlobal(const std::st
// If the linkage is specified and is external, then no initializer is
// present.
Constant *Init = nullptr;
- if (!HasLinkage || (Linkage != GlobalValue::ExternalWeakLinkage &&
- Linkage != GlobalValue::ExternalLinkage)) {
+ if (!HasLinkage ||
+ !GlobalValue::isValidDeclarationLinkage(
+ (GlobalValue::LinkageTypes)Linkage)) {
if (ParseGlobalValue(Ty, Init))
return true;
}
Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=269184&r1=269183&r2=269184&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Wed May 11 08:51:39 2016
@@ -503,8 +503,7 @@ static void forEachUser(const Value *Use
}
void Verifier::visitGlobalValue(const GlobalValue &GV) {
- Assert(!GV.isDeclaration() || GV.hasExternalLinkage() ||
- GV.hasExternalWeakLinkage(),
+ Assert(!GV.isDeclaration() || GV.hasValidDeclarationLinkage(),
"Global is external, but doesn't have external or weak linkage!", &GV);
Assert(GV.getAlignment() <= Value::MaximumAlignment,
More information about the llvm-commits
mailing list