[all-commits] [llvm/llvm-project] 47a149: [FileCheck][NFC] Complete FileCheckDiag class hier...

Joel E. Denny via All-commits all-commits at lists.llvm.org
Wed May 6 08:44:45 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 47a149729108ccce763c39ac64336cbc2cfcf490
      https://github.com/llvm/llvm-project/commit/47a149729108ccce763c39ac64336cbc2cfcf490
  Author: Joel E. Denny <jdenny.ornl at gmail.com>
  Date:   2026-05-06 (Wed, 06 May 2026)

  Changed paths:
    M llvm/include/llvm/FileCheck/FileCheck.h
    M llvm/lib/FileCheck/FileCheck.cpp
    M llvm/lib/FileCheck/FileCheckImpl.h
    M llvm/unittests/FileCheck/FileCheckTest.cpp
    M llvm/utils/FileCheck/FileCheck.cpp

  Log Message:
  -----------
  [FileCheck][NFC] Complete FileCheckDiag class hierarchy (#195571)

This patch depends on PR #195569 and finishes its effort to decouple the
`-dump-input` presentation layer (in
`llvm/utils/FileCheck/FileCheck.cpp`) and the FileCheck library's
diagnostic emission (in `llvm/lib/FileCheck/FileCheck.cpp`).

The focus of this patch is finally eliminating `enum MatchType` and
completing the `FileCheckDiag` class hierarchy. That enables the
following improvements.

Replace MatchTy and InputRange
==============================

`-dump-input` needs some means to determine (1) whether some notes
should be filtered in by `-dump-input-filter=error`, and (2) where to
place some notes in the input dump. Without this patch series, the
FileCheck library provides that information by copying the following
from a match result to any note that does not have its own versions: (1)
the `MatchType`, which determines error status, and (2) the input range
so that `-dump-input` can place the note next to the match result.
However, this copied information is redundant as it is already part of
the associated match result, and semantically it does not really apply
to the note itself.

Furthermore, for a note that does not have a match location (e.g., the
FileCheck library does not include match locations when emitting notes
about variable substitutions), the FileCheck library is responsible for
reducing the copied location to an empty range as a special case that
`-dump-input` understands means it should not add a marker (like `^~~`),
which would be misleading in the input dump. However, that means a note
can never have a real input range that is empty and that thus refers to
just a single position.

This interaction is too subtle, even in the case of just `-dump-input`.
Moreover, it is easy to imagine alternative diagnostic presentation
layers where it would be unhelpful and thus more misleading. For
example, imagine (this is just a thought experiment, and I have no plans
for this) an HTML-based presentation where notes appear in pop-up
windows when clicking on match results. A copied error status and
location is then not relevant for notes. Association with a match result
still is relevant.

This patch removes the `MatchTy` and `InputRange` fields from
`FieldCheckDiag`. It replaces `MatchTy` with `Status` fields in just the
`MatchResultDiag` hierarchy. To replace `InputRange`, it exposes a match
range as a `std::optional`, and it adds a search range to
`MatchResultDiag` (used now for `MatchNoneDiag` and, in the future,
`-dump-input` will present search ranges upon any error). Thus, this
patch relieves the FileCheck library of the above
`-dump-input`-specific responsibilities, and `-dump-input` is now able
to cleanly examine the `FileCheckDiag` series for each required
property.

Clean up getMarker
==================

Because of the now complete `FileCheckDiag` class hierarchy, this patch
is able to clean up the `getMarker` function for `-dump-input`. Without
this patch, `getMarker` encodes the lead character, color, message, and
error status individually for every possible `MatchType`. With this
patch, `getMarker` instead encodes the logic of how the marker
properties are generally chosen at the top of the `FileCheckDiag`
hierarchy, and then it overrides those choices where needed lower in the
hierarchy. Again, it is now easier for a diagnostic presentation layer
to reason about diagnostics.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list