[lld] r205643 - Split a utility function not to use goto statement.

Rui Ueyama ruiu at google.com
Fri Apr 4 11:34:40 PDT 2014


Author: ruiu
Date: Fri Apr  4 13:34:40 2014
New Revision: 205643

URL: http://llvm.org/viewvc/llvm-project?rev=205643&view=rev
Log:
Split a utility function not to use goto statement.

Modified:
    lld/trunk/lib/Core/SymbolTable.cpp

Modified: lld/trunk/lib/Core/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/SymbolTable.cpp?rev=205643&r1=205642&r2=205643&view=diff
==============================================================================
--- lld/trunk/lib/Core/SymbolTable.cpp (original)
+++ lld/trunk/lib/Core/SymbolTable.cpp Fri Apr  4 13:34:40 2014
@@ -132,22 +132,25 @@ static MergeResolution mergeSelect(Defin
   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





More information about the llvm-commits mailing list