Reputation: 411
I am iterating over the Module's function lists as shown below.
I am seeking for a way to find out if a Function *f
is a declaration or a definition. (By dumping the function it seems that the list contains the two types.)
for (Module::iterator f = M->begin(), fend = M->end(); f != fend; ++f) {
...
}
Upvotes: 3
Views: 1729
Reputation: 7146
From the Function
manual:
If the
BasicBlock
list is empty, this indicates that theFunction
is actually a function declaration: the actual body of the function hasn’t been linked in yet.
and in the next section on Important Public Members of the Function, you'll find the function you want:
bool
isDeclaration
()Return whether or not the Function has a body defined. If the function is “external”, it does not have a body, and thus must be resolved by linking with a function defined in a different translation unit.
which does the emptiness check for you.
Upvotes: 4