diff options
| author | Rui Ueyama <ruiu@google.com> | 2013-10-11 03:48:06 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2013-10-11 03:48:06 +0000 |
| commit | d542b9e53ae70b39e1774e00cf5e45ff495a1989 (patch) | |
| tree | 1976463f26bf6599a97e7aae66cc8307d9706b19 /lld/lib/Core | |
| parent | 80c33aa3d7d775ec0688689171def834d2618686 (diff) | |
| download | bcm5719-llvm-d542b9e53ae70b39e1774e00cf5e45ff495a1989.tar.gz bcm5719-llvm-d542b9e53ae70b39e1774e00cf5e45ff495a1989.zip | |
Use switch instead of if, and handle all enum values.
This patch also handles errors other than no_more_files error. They were silently
ignored.
llvm-svn: 192415
Diffstat (limited to 'lld/lib/Core')
| -rw-r--r-- | lld/lib/Core/Resolver.cpp | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp index ecf2687b357..859675c045b 100644 --- a/lld/lib/Core/Resolver.cpp +++ b/lld/lib/Core/Resolver.cpp @@ -289,29 +289,41 @@ void Resolver::addAtoms(const std::vector<const DefinedAtom*>& newAtoms) { } } -// ask symbol table if any definitionUndefined atoms still exist -// if so, keep searching libraries until no more atoms being added +// Ask symbol table if any undefined atoms still exist. If so, keep searching +// libraries until no more atoms being added. void Resolver::resolveUndefines() { ScopedTask task(getDefaultDomain(), "resolveUndefines"); - while (ErrorOr<File &> nextFile = _context.nextFile()) { + StringRef errorMessage; + for (;;) { + ErrorOr<File &> file = _context.nextFile(); _context.setResolverState(Resolver::StateNoChange); - if (error_code(nextFile) == InputGraphError::no_more_files) - break; - if (nextFile->kind() == File::kindObject) { - assert(!nextFile->hasOrdinal()); - nextFile->setOrdinal(_context.getNextOrdinalAndIncrement()); - handleFile(*nextFile); - } - if (nextFile->kind() == File::kindArchiveLibrary) { - if (!nextFile->hasOrdinal()) - nextFile->setOrdinal(_context.getNextOrdinalAndIncrement()); - handleArchiveFile(*nextFile); + if (error_code(file) == InputGraphError::no_more_files) + return; + if (!file) { + llvm::errs() << "Error occurred in nextFile: " + << error_code(file).message() << "\n"; + return; } - if (nextFile->kind() == File::kindSharedLibrary) { - if (!nextFile->hasOrdinal()) - nextFile->setOrdinal(_context.getNextOrdinalAndIncrement()); - handleSharedLibrary(*nextFile); + + switch (file->kind()) { + case File::kindObject: + assert(!file->hasOrdinal()); + file->setOrdinal(_context.getNextOrdinalAndIncrement()); + handleFile(*file); + break; + case File::kindArchiveLibrary: + if (!file->hasOrdinal()) + file->setOrdinal(_context.getNextOrdinalAndIncrement()); + handleArchiveFile(*file); + break; + case File::kindSharedLibrary: + if (!file->hasOrdinal()) + file->setOrdinal(_context.getNextOrdinalAndIncrement()); + handleSharedLibrary(*file); + break; + case File::kindLinkerScript: + llvm_unreachable("linker script should not be returned by nextFile()"); } } } |

