Without this patch, --dump-input annotations on a single input line
are sorted by the associated directive's check-file line. That seemed
fine because that's often identical to the order in which FileCheck
looks for matches for those directives.
The first problem is that an --implicit-check-not pattern has no
check-file line. The logical equivalent is sorting in command-line
order, but that's not implemented.
The second problem is that, unlike a directive, an
--implicit-check-not pattern applies at many points, between many
different pairs of directives. However, sorting in command-line order
gathers all its associated diagnostics together at one point in an
input line's list of annotations.
In general, it seems to be easier to understand FileCheck's logic when
annotations on a single input line are sorted in the order FileCheck
produced the associated diagnostics, so this patch makes that change.
As documented in the patch, the annotation sort order is also
especially relevant to CHECK-LABEL, CHECK-NOT, and CHECK-DAG, so
this patch updates or extends tests to check the sort makes sense for
them. (However, the sort for CHECK-DAG annotations should not
actually be altered by this patch.)
With 3 CHECK directives, I would expect 4 blocks of implicit checks being tested:
Unless I misunderstood, I would expect directive #3 to fail, i.e. "again" is found between "wor" and '!'. However the implicit check that fail is shown after the third CHECK directive.