Currently, if the assembler encounters an error after parsing (such as an out-of-range fixup), it reports this as a fatal error, and so stops after the first error. However, for most of these there is an obvious way to recover after emitting the error, such as emitting the fixup with a value of zero. This means that we can report on all of the errors in a file, not just the first one. MCContext::reportError records the fact that an error was encountered, so we won't actually emit an object file with the incorrect contents.
Details
Diff Detail
Event Timeline
Looks like a good idea to me! Writing multiple files worth of tests for diagnostics was a pain in the neck, and I expect the testing has suffered as a result.
Tim.
This is totally reasonable.
Longer term, I'd love to see a more holistic plan for diagnostics in the assembler. Right now they're in broadly two categories "(mostly) syntax related problems we detect directly in the parser" and "everything else, thrown in wherever we would otherwise have crashed." The former case could use a bit of cleanup but is generally fine. The latter is completely haphazard, however.
I'd love to have a moral equivalent to a Sema pass or two that we could run over the collected state of things for the assembler. I'm (totally hand waving) thinking one right after parsing that just wants a more global view of the whole file so it can find things like unresolved forward references to local labels. Then one after layout which can find things like out of range fix-ups, "there's not legal relocations for this thing," et. al..
With something like that, the post-parser diagnostics all move into there. All the places we current do error checking in the AsmBackend and related can now assume good input, as they've had the input validated earlier, so the diagnostics there become assert() calls. The Sema passes get used by the assembler, but not the compiler (unless there's inline assembler, in which case we still need them). That way we split out the currently merged functionality of catching compiler backend bugs and catching user error in assembly files. By doing so, we get both a cleaner layering and a faster compiler backend as it will be able to do a bit less work.