Split a utility function not to use goto statement.

llvm-svn: 205643
This commit is contained in:
Rui Ueyama 2014-04-04 18:34:40 +00:00
parent e8af3e48fd
commit 331f482cf6
1 changed files with 17 additions and 14 deletions

View File

@ -132,22 +132,25 @@ static MergeResolution mergeSelect(DefinedAtom::Merge first,
return mergeCases[first][second];
}
static uint64_t getSizeFollowReferences(const DefinedAtom *atom, uint32_t kind) {
uint64_t size = 0;
redo:
while (atom) {
for (const Reference *r : *atom) {
static const DefinedAtom *followReference(const DefinedAtom *atom,
uint32_t kind) {
for (const Reference *r : *atom)
if (r->kindNamespace() == Reference::KindNamespace::all &&
r->kindArch() == Reference::KindArch::all &&
r->kindValue() == kind) {
atom = cast<DefinedAtom>(r->target());
size += atom->size();
goto redo;
}
}
break;
r->kindValue() == kind)
return cast<const DefinedAtom>(r->target());
return nullptr;
}
static uint64_t getSizeFollowReferences(const DefinedAtom *atom,
uint32_t kind) {
uint64_t size = 0;
for (;;) {
atom = followReference(atom, kind);
if (!atom)
return size;
size += atom->size();
}
}
// Returns the size of the section containing the given atom. Atoms in the same