add comments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135164 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2011-07-14 18:12:44 +00:00
parent 6c48244973
commit 97d9730a59

View File

@ -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();