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.
#define BAD_FUNCTION() badFunction() // LINE-ANCHOR: BAD_FUNC // Further down in the file BAD_FUNCTION(); CHECK-NOTES: [[@LINE-1]]:3: warning: called a bad function CHECK-NOTES :[[#BAD-FUNC]]:24: note: expanded from macro 'BAD_FUNCTION'
Relative offset are also supported using the same syntax for variables.