[llvm-dev] [cfe-dev] [FileCheck] RFC: Add support for line anchors. (original) (raw)
Nathan James via llvm-dev llvm-dev at lists.llvm.org
Fri Jul 17 13:38:34 PDT 2020
- Previous message: [llvm-dev] [cfe-dev] [FileCheck] RFC: Add support for line anchors.
- Next message: [llvm-dev] [cfe-dev] [FileCheck] RFC: Add support for line anchors.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, 2020-07-17 at 14:59 -0400, Joel E. Denny via cfe-dev wrote:
On Fri, Jul 17, 2020 at 2:52 PM Joel E. Denny <jdenny.ornl at gmail.com> wrote: > Hi Nathan, > > On Fri, Jul 17, 2020 at 12:23 PM Nathan James via cfe-dev <_ _> cfe-dev at lists.llvm.org> wrote: > > Hello, > > > > I was wondering about extending FileCheck to enable creating line > > anchors. These are numeric variables that hold the value of the > > line > > number that where they were defined. > > I think something like this could be useful. However, I think it > would be more useful to have a general directive for defining > FileCheck variables inline without trying to capture from input. > For example: > >
_ _> #define BADFUNCTION() badFunction() // CHECK-DEFINE:_ _> [[#BADFUNC:@LINE]]_ _> // Further down in the file_ _> BADFUNCTION();_ _> CHECK-NOTES: [[@LINE-1]]:3: warning: called a bad function_ _> CHECK-NOTES :[[#BADFUNC]]:3: note: expanded from macro_ _> 'BADFUNCTION'_ _>> > The exact syntax is debatable. > > I think this form is more useful because it can also define strings > or numerics (or maybe even patterns) to be reused in multiple > FileCheck directives across multiple FileCheck calls from different > RUN lines. Currently, you either have to capture such a variable > from the input or specify it with -D on every FileCheck call that > needs it. > > James Henderson: Weren't you working on something like this? > > Thanks. > > Joel > > > The motivation for this comes from test cases using clang-based > > diagnostics which often include notes attached to source > > locations in > > different parts of the file. In order to test for the correct > > location > > of the note, the line number has to be written explicitly or as > > an, > > often large, offset to the current line. This harms both > > readability > > and maintainability. Using this new system one could append a > > line of > > interest with an anchor-comment and refer back to it inside > > FileCheck.Also, just in case you weren't aware, there is a Clang facility for checking its own diagnostics: http://clang.llvm.org/doxygen/classclang11VerifyDiagnosticConsumer.html#details You'd put a directive for each diagnostic on or near the line it cites. Joel The use case I was mainly thinking of was clang tools, specifically clang-tidy. There you need to be able to check diagnostics and fix-its in one file ideally. Right now you can't use the VerifyDiagnosticConsumer in there and it also won't be able to veryify fix-its.
~Nathan
> > I have created a basic patch that implements this here > > https://reviews.llvm.org/D84037 but it definitely needs a few > > looks > > over by people who are more clued up on the internal of > > FileCheck. > > > > The current syntax, based off this patch, is as follows: > > - Added a command line option called
anchor-prefixwhich is a > > comma-seperated list of prefixes to be used when declaring > > anchors. > > This is defaulted toLINE-ANCHOR> > - To declare a anchor in the test file use > >LINE-ANCHOR: ANCHORNAME> > note: If you specify a different anchor-prefix using the > > command > > line, use that name instead ofLINE-ANCHOR> > ANCHORNAME Follows the rules all other variable names aside > > from > > the fact it can't start with '$'. > > - When referring to an anchor in a check use the same numeric > > variable syntax that FileCheck already supports: > >CHECK: [[#ANCHORNAME]][[#ANCHORNAME+1]]> > > > Here is a brief (contrived) example of the usage of this: > >_ _> > #define BADFUNCTION() badFunction() // LINE-ANCHOR: BADFUNC_ _> > // Further down in the file_ _> > BADFUNCTION();_ _> > CHECK-NOTES: [[@LINE-1]]:3: warning: called a bad function_ _> > CHECK-NOTES :[[#BAD-FUNC]]:3: note: expanded from macro_ _> > 'BADFUNCTION'_ _> >> > > > Regards, > > Nathan James > > > > _> > ________________________ > > cfe-dev mailing list > > cfe-dev at lists.llvm.org > > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
cfe-dev mailing list cfe-dev at lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
- Previous message: [llvm-dev] [cfe-dev] [FileCheck] RFC: Add support for line anchors.
- Next message: [llvm-dev] [cfe-dev] [FileCheck] RFC: Add support for line anchors.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]