================ @@ -3458,8 +3461,34 @@ A range can also be specified by ``<n>-<m>``. For example: In this example, the diagnostic may appear only once, if at all. +.. _DiagnosticMatching: + +Matching Modes +~~~~~~~~~~~~~~ + +The default matching mode is simple string, which looks for the expected text +that appears between the first `{{` and `}}` pair of the comment. The string is +interpreted just as-is, with one exception: the sequence `\n` is converted to a +single newline character. This mode matches the emitted diagnostic when the +text appears as a substring at any position of the emitted message. + +To enable matching against desired strings that contain `}}` or `{{`, the +string-mode parser accepts opening delimiters of more than two curly braces, +like `{{{`. It then looks for a closing delimiter of equal "width" (i.e `}}}`). +For example: + +.. code-block:: c++ + + // expected-note {{{evaluates to '{{2, 3, 4}} == {0, 3, 4}'}}} + +If your expected text contains `{{{` (three braces), then it may be delimited +with `{{{{` (four braces), and so on. If your expected text contains enough +repeated `{`s to fill up a `ptrdiff_t`, then you'll definitely crash the +parser, possibly even as late as the delimiter handling. ---------------- sethp wrote:
Per @erichkeane's comment, this paragraph should be reworded, maybe to something like? ```suggestion The parser does not try to limit the width of a delimiter, so if your expected text contains `{{{` (three braces), then it may be delimited with `{{{{` (four braces), and so on. ``` https://github.com/llvm/llvm-project/pull/77326 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits