forked from OSchip/llvm-project
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
This commit is contained in:
parent
80c33aa3d7
commit
d542b9e53a
|
@ -289,29 +289,41 @@ void Resolver::addAtoms(const std::vector<const DefinedAtom*>& newAtoms) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ask symbol table if any definitionUndefined atoms still exist
|
// Ask symbol table if any undefined atoms still exist. If so, keep searching
|
||||||
// if so, keep searching libraries until no more atoms being added
|
// libraries until no more atoms being added.
|
||||||
void Resolver::resolveUndefines() {
|
void Resolver::resolveUndefines() {
|
||||||
ScopedTask task(getDefaultDomain(), "resolveUndefines");
|
ScopedTask task(getDefaultDomain(), "resolveUndefines");
|
||||||
|
|
||||||
while (ErrorOr<File &> nextFile = _context.nextFile()) {
|
StringRef errorMessage;
|
||||||
|
for (;;) {
|
||||||
|
ErrorOr<File &> file = _context.nextFile();
|
||||||
_context.setResolverState(Resolver::StateNoChange);
|
_context.setResolverState(Resolver::StateNoChange);
|
||||||
if (error_code(nextFile) == InputGraphError::no_more_files)
|
if (error_code(file) == InputGraphError::no_more_files)
|
||||||
|
return;
|
||||||
|
if (!file) {
|
||||||
|
llvm::errs() << "Error occurred in nextFile: "
|
||||||
|
<< error_code(file).message() << "\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (file->kind()) {
|
||||||
|
case File::kindObject:
|
||||||
|
assert(!file->hasOrdinal());
|
||||||
|
file->setOrdinal(_context.getNextOrdinalAndIncrement());
|
||||||
|
handleFile(*file);
|
||||||
break;
|
break;
|
||||||
if (nextFile->kind() == File::kindObject) {
|
case File::kindArchiveLibrary:
|
||||||
assert(!nextFile->hasOrdinal());
|
if (!file->hasOrdinal())
|
||||||
nextFile->setOrdinal(_context.getNextOrdinalAndIncrement());
|
file->setOrdinal(_context.getNextOrdinalAndIncrement());
|
||||||
handleFile(*nextFile);
|
handleArchiveFile(*file);
|
||||||
}
|
break;
|
||||||
if (nextFile->kind() == File::kindArchiveLibrary) {
|
case File::kindSharedLibrary:
|
||||||
if (!nextFile->hasOrdinal())
|
if (!file->hasOrdinal())
|
||||||
nextFile->setOrdinal(_context.getNextOrdinalAndIncrement());
|
file->setOrdinal(_context.getNextOrdinalAndIncrement());
|
||||||
handleArchiveFile(*nextFile);
|
handleSharedLibrary(*file);
|
||||||
}
|
break;
|
||||||
if (nextFile->kind() == File::kindSharedLibrary) {
|
case File::kindLinkerScript:
|
||||||
if (!nextFile->hasOrdinal())
|
llvm_unreachable("linker script should not be returned by nextFile()");
|
||||||
nextFile->setOrdinal(_context.getNextOrdinalAndIncrement());
|
|
||||||
handleSharedLibrary(*nextFile);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue