summaryrefslogtreecommitdiff
path: root/lib/VMCore/Globals.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-07-14 18:12:44 +0000
committerChris Lattner <sabre@nondot.org>2011-07-14 18:12:44 +0000
commit97d9730a59fbd4e656d2c34f3b92d2feb4d9d575 (patch)
treef1f6821a4943eb99e28ada6e8f29464a4758070e /lib/VMCore/Globals.cpp
parent6c48244973b3c3286af54dddb98412d2820b26b5 (diff)
downloadllvm-97d9730a59fbd4e656d2c34f3b92d2feb4d9d575.tar.gz
llvm-97d9730a59fbd4e656d2c34f3b92d2feb4d9d575.tar.bz2
llvm-97d9730a59fbd4e656d2c34f3b92d2feb4d9d575.tar.xz
add comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135164 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Globals.cpp')
-rw-r--r--lib/VMCore/Globals.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/VMCore/Globals.cpp b/lib/VMCore/Globals.cpp
index 0e0d667392..76fc5a9492 100644
--- a/lib/VMCore/Globals.cpp
+++ b/lib/VMCore/Globals.cpp
@@ -63,12 +63,14 @@ void GlobalValue::setAlignment(unsigned Align) {
}
bool GlobalValue::isDeclaration() const {
+ // Globals are definitions if they have an initializer.
if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(this))
return GV->getNumOperands() == 0;
+ // Functions are definitions if they have a body.
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();