diff options
author | Rui Ueyama <ruiu@google.com> | 2014-04-04 18:34:40 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2014-04-04 18:34:40 +0000 |
commit | 331f482cf6205ec74fff52031c88b3bc7fbad9db (patch) | |
tree | 11a3d419759888db8c94e3d18b6dbf8d894add6d /lld/lib/Core/SymbolTable.cpp | |
parent | e8af3e48fd5dffc710a9148282e26e5ab6d65e1d (diff) | |
download | bcm5719-llvm-331f482cf6205ec74fff52031c88b3bc7fbad9db.tar.gz bcm5719-llvm-331f482cf6205ec74fff52031c88b3bc7fbad9db.zip |
Split a utility function not to use goto statement.
llvm-svn: 205643
Diffstat (limited to 'lld/lib/Core/SymbolTable.cpp')
-rw-r--r-- | lld/lib/Core/SymbolTable.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/lld/lib/Core/SymbolTable.cpp b/lld/lib/Core/SymbolTable.cpp index cb0ff756347..a6620753424 100644 --- a/lld/lib/Core/SymbolTable.cpp +++ b/lld/lib/Core/SymbolTable.cpp @@ -132,22 +132,25 @@ static MergeResolution mergeSelect(DefinedAtom::Merge first, return mergeCases[first][second]; } -static uint64_t getSizeFollowReferences(const DefinedAtom *atom, uint32_t kind) { +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) + return cast<const DefinedAtom>(r->target()); + return nullptr; +} + +static uint64_t getSizeFollowReferences(const DefinedAtom *atom, + uint32_t kind) { uint64_t size = 0; -redo: - while (atom) { - 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; + for (;;) { + atom = followReference(atom, kind); + if (!atom) + return size; + size += atom->size(); } - return size; } // Returns the size of the section containing the given atom. Atoms in the same |