This is an archive of the discontinued LLVM Phabricator instance.

[FileCheck][WIP] Added support for line anchors
Needs ReviewPublic

Authored by njames93 on Jul 17 2020, 8:49 AM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

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.
[[#NOTE-WORTHY+2]]

Diff Detail

Event Timeline

njames93 created this revision.Jul 17 2020, 8:49 AM
njames93 edited the summary of this revision. (Show Details)Jul 17 2020, 9:35 AM
njames93 edited the summary of this revision. (Show Details)