summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-07-14 18:10:41 +0000
committerChris Lattner <sabre@nondot.org>2011-07-14 18:10:41 +0000
commit923053a1d66dd8729523913ea02de2bf7f3fbf50 (patch)
treebca387289b6ee025b1398c55831cfa9645201bd3 /llvm/lib/VMCore
parentd616cf3497195ff070115bafd46c98cfa928a15a (diff)
downloadbcm5719-llvm-923053a1d66dd8729523913ea02de2bf7f3fbf50.tar.gz
bcm5719-llvm-923053a1d66dd8729523913ea02de2bf7f3fbf50.zip
consolidate GlobalValue::isDeclaration into one
non-virtual function. llvm-svn: 135163
Diffstat (limited to 'llvm/lib/VMCore')
-rw-r--r--llvm/lib/VMCore/Globals.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/llvm/lib/VMCore/Globals.cpp b/llvm/lib/VMCore/Globals.cpp
index dfb88f49277..0e0d667392b 100644
--- a/llvm/lib/VMCore/Globals.cpp
+++ b/llvm/lib/VMCore/Globals.cpp
@@ -61,6 +61,19 @@ void GlobalValue::setAlignment(unsigned Align) {
Alignment = Log2_32(Align) + 1;
assert(getAlignment() == Align && "Alignment representation error!");
}
+
+bool GlobalValue::isDeclaration() const {
+ if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(this))
+ return GV->getNumOperands() == 0;
+
+ if (const Function *F = dyn_cast<Function>(this))
+ return F->empty();
+
+ const GlobalAlias *GA = cast<GlobalAlias>(this);
+ if (const GlobalValue *AV = GA->getAliasedGlobal())
+ return AV->isDeclaration();
+ return false;
+}
//===----------------------------------------------------------------------===//
// GlobalVariable Implementation
@@ -202,14 +215,6 @@ void GlobalAlias::eraseFromParent() {
getParent()->getAliasList().erase(this);
}
-bool GlobalAlias::isDeclaration() const {
- const GlobalValue* AV = getAliasedGlobal();
- if (AV)
- return AV->isDeclaration();
- else
- return false;
-}
-
void GlobalAlias::setAliasee(Constant *Aliasee) {
assert((!Aliasee || Aliasee->getType() == getType()) &&
"Alias and aliasee types should match!");
OpenPOWER on IntegriCloud