[PATCH] D84037: [FileCheck][WIP] Added support for line anchors

Nathan James via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 17 08:49:45 PDT 2020


njames93 created this revision.
Herald added subscribers: llvm-commits, thopre, hiraditya, arichardson.
Herald added a project: LLVM.

Numerous test files using clang based diagnostics often include notes attached to them, potentially in completely different parts of the file.
If you want to ensure the note is displayed in the correct place you either have to specify the line number explicitly or as a relative offset from the line where the `CHECK` directive is.

The first approach always looks messy. The second, using `@LINE+/-offset` looks messier the larger the offset grows.
Aside from looking messy they also increase the risk of a failing test if something, potentially unrelated, is modified in the test file.

This patch tries to simplify this by allowing you to declare variable which expand to the line number they were defined on and can later be referred to in `CHECK` lines.

    SomethingNoteWorthy(); // LINE-ANCHOR: NOTE-WORTHY
  ...
  CHECK-NOTES :[[#NOTE-WORTHY]:3: note: SomethingNoteWorthy called here

Relative offset are also supported using the same syntax for variables.
`[[#NOTE-WORTHY+2]]`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84037

Files:
  llvm/include/llvm/Support/FileCheck.h
  llvm/lib/Support/FileCheck.cpp
  llvm/lib/Support/FileCheckImpl.h
  llvm/test/FileCheck/line-anchor-errors.txt
  llvm/test/FileCheck/line-anchors.txt
  llvm/unittests/Support/FileCheckTest.cpp
  llvm/utils/FileCheck/FileCheck.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84037.278789.patch
Type: text/x-patch
Size: 12027 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200717/bc6e0b3c/attachment.bin>


More information about the llvm-commits mailing list