git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135164
91177308-0d34-0410-b5e6-
96231b3b80d8
}
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();