diff options
author | Chris Lattner <sabre@nondot.org> | 2011-07-14 18:10:41 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-07-14 18:10:41 +0000 |
commit | 6c48244973b3c3286af54dddb98412d2820b26b5 (patch) | |
tree | d4ab24372f32bd8a727541d1ec470cd06e812ee8 /lib | |
parent | 791feea10071223886e2fe2bfa0e1f4cb2c0ce74 (diff) | |
download | llvm-6c48244973b3c3286af54dddb98412d2820b26b5.tar.gz llvm-6c48244973b3c3286af54dddb98412d2820b26b5.tar.bz2 llvm-6c48244973b3c3286af54dddb98412d2820b26b5.tar.xz |
consolidate GlobalValue::isDeclaration into one
non-virtual function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135163 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/VMCore/Globals.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/VMCore/Globals.cpp b/lib/VMCore/Globals.cpp index dfb88f4927..0e0d667392 100644 --- a/lib/VMCore/Globals.cpp +++ b/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!"); |