diff options
author | Thomas Preud'homme <thomasp@graphcore.ai> | 2020-12-15 00:58:16 +0000 |
---|---|---|
committer | Thomas Preud'homme <thomasp@graphcore.ai> | 2021-03-03 08:20:39 +0000 |
commit | 09c35739035e23279e9369b8bf048288781a3d60 (patch) | |
tree | 6ece767ae039f7f613ab3aba66285bfa5de6b546 /llvm/utils/FileCheck/FileCheck.cpp | |
parent | 6e3946c9f558adfddfd98a51721baccd8b17bb85 (diff) | |
download | llvm-09c35739035e23279e9369b8bf048288781a3d60.zip llvm-09c35739035e23279e9369b8bf048288781a3d60.tar.gz llvm-09c35739035e23279e9369b8bf048288781a3d60.tar.bz2 |
[FileCheck] Do not skip end of line in diagnostics
When commit da108b4ed4e6e7267701e76d5fd3b87609c9ab77 introduced
the CHECK-NEXT directive, it added logic to skip to the next line when
printing a diagnostic if the current matching position is at the end of
a line. This was fine while FileCheck did not support regular expression
but since it does now it can be confusing when the pattern to match
starts with the expectation of a newline (e.g. CHECK-NEXT: {{\n}}foo).
It is also inconsistent with the column information in the diagnostic
which does point to the end of line.
This commit removes this logic altogether, such that failure to match
diagnostic for such cases would show the end of line and be consistent
with the column information. The commit also adapts all existing
testcases accordingly.
Note to reviewers: An alternative approach would be to restrict the code
to only skip to the next line if the first character of the pattern is
known not to match a whitespace-like character. This would respect the
original intent but keep the inconsistency in terms of column info and
requires more code. I've only chosen this current approach by laziness
and would be happy to restrict the logic instead.
Reviewed By: jdenny, jhenderson
Differential Revision: https://reviews.llvm.org/D93341
Diffstat (limited to 'llvm/utils/FileCheck/FileCheck.cpp')
-rw-r--r-- | llvm/utils/FileCheck/FileCheck.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/llvm/utils/FileCheck/FileCheck.cpp b/llvm/utils/FileCheck/FileCheck.cpp index a509c4d..ebee55b 100644 --- a/llvm/utils/FileCheck/FileCheck.cpp +++ b/llvm/utils/FileCheck/FileCheck.cpp @@ -248,7 +248,10 @@ static void DumpInputAnnotationHelp(raw_ostream &OS) { // Labels for input lines. OS << " - "; WithColor(OS, raw_ostream::SAVEDCOLOR, true) << "L:"; - OS << " labels line number L of the input file\n"; + OS << " labels line number L of the input file\n" + << " An extra space is added after each input line to represent" + << " the\n" + << " newline character\n"; // Labels for annotation lines. OS << " - "; @@ -662,15 +665,16 @@ static void DumpAnnotatedInput(raw_ostream &OS, const FileCheckRequest &Req, COS.resetColor(); else if (WasInMatch && !InMatch) COS.changeColor(raw_ostream::CYAN, true, true); - if (*InputFilePtr == '\n') + if (*InputFilePtr == '\n') { Newline = true; - else + COS << ' '; + } else COS << *InputFilePtr; ++InputFilePtr; } } *LineOS << '\n'; - unsigned InputLineWidth = InputFilePtr - InputFileLine - Newline; + unsigned InputLineWidth = InputFilePtr - InputFileLine; // Print any annotations. while (AnnotationItr != AnnotationEnd && |