[lld] r192415 - Use switch instead of if, and handle all enum values.
Rui Ueyama
ruiu at google.com
Thu Oct 10 20:48:06 PDT 2013
Author: ruiu
Date: Thu Oct 10 22:48:06 2013
New Revision: 192415
URL: http://llvm.org/viewvc/llvm-project?rev=192415&view=rev
Log:
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.
Modified:
lld/trunk/lib/Core/Resolver.cpp
Modified: lld/trunk/lib/Core/Resolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=192415&r1=192414&r2=192415&view=diff
==============================================================================
--- lld/trunk/lib/Core/Resolver.cpp (original)
+++ lld/trunk/lib/Core/Resolver.cpp Thu Oct 10 22:48:06 2013
@@ -289,29 +289,41 @@ void Resolver::addAtoms(const std::vecto
}
}
-// 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()");
}
}
}
More information about the llvm-commits
mailing list