diff --git a/tools/gccld/gccld.cpp b/tools/gccld/gccld.cpp index db03b208b91..41c176f8690 100644 --- a/tools/gccld/gccld.cpp +++ b/tools/gccld/gccld.cpp @@ -173,7 +173,7 @@ static void BuildLinkItems( cl::list::const_iterator libIt = Libraries.begin(); int libPos = -1, filePos = -1; - while ( 1 ) { + while ( libIt != Libraries.end() || fileIt != Files.end() ) { if (libIt != Libraries.end()) libPos = Libraries.getPosition(libIt - Libraries.begin()); else @@ -189,11 +189,10 @@ static void BuildLinkItems( } else if (libPos != -1 && (filePos == -1 || libPos < filePos)) { // Add a library Items.push_back(std::make_pair(*libIt++, true)); - } else { - break; // we're done with the list } } } + int main(int argc, char **argv, char **envp) { cl::ParseCommandLineOptions(argc, argv, " llvm linker for GCC\n"); sys::PrintStackTraceOnErrorSignal(); diff --git a/tools/llvm-ld/llvm-ld.cpp b/tools/llvm-ld/llvm-ld.cpp index 41d9510d298..8bd2cc8376b 100644 --- a/tools/llvm-ld/llvm-ld.cpp +++ b/tools/llvm-ld/llvm-ld.cpp @@ -390,7 +390,7 @@ static void BuildLinkItems( cl::list::const_iterator libIt = Libraries.begin(); int libPos = -1, filePos = -1; - while ( 1 ) { + while ( libIt != Libraries.end() || fileIt != Files.end() ) { if (libIt != Libraries.end()) libPos = Libraries.getPosition(libIt - Libraries.begin()); else @@ -406,8 +406,6 @@ static void BuildLinkItems( } else if (libPos != -1 && (filePos == -1 || libPos < filePos)) { // Add a library Items.push_back(std::make_pair(*libIt++, true)); - } else { - break; // we're done with the list } } }