From 8561721bcecbab6d97e8a66a1910e182c1f1b5cc Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 14 Jul 2011 18:12:44 +0000 Subject: add comments. llvm-svn: 135164 --- llvm/lib/VMCore/Globals.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'llvm') diff --git a/llvm/lib/VMCore/Globals.cpp b/llvm/lib/VMCore/Globals.cpp index 0e0d667392b..76fc5a94923 100644 --- a/llvm/lib/VMCore/Globals.cpp +++ b/llvm/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(this)) return GV->getNumOperands() == 0; + // Functions are definitions if they have a body. if (const Function *F = dyn_cast(this)) return F->empty(); - + const GlobalAlias *GA = cast(this); if (const GlobalValue *AV = GA->getAliasedGlobal()) return AV->isDeclaration(); -- cgit v1.2.3