This is an archive of the discontinued LLVM Phabricator instance.

[FileCheck] Parse command-line options from FILECHECK_OPTS
ClosedPublic

Authored by jdenny on Oct 22 2018, 11:37 AM.

Details

Summary

This feature makes it easy to tune FileCheck diagnostic output when
running the test suite via ninja, a bot, or an IDE. For example:

$ FILECHECK_OPTS='-color -v -dump-input-on-failure' \
  LIT_FILTER='OpenMP/for_codegen.cpp' ninja check-clang \
  | less -R

Diff Detail

Event Timeline

jdenny created this revision.Oct 22 2018, 11:37 AM
jdenny updated this revision to Diff 172659.Nov 5 2018, 2:42 PM
jdenny edited the summary of this revision. (Show Details)

Ping. Rebased.

This is a small patch to FileCheck that I think could be beneficial throughout LLVM. Does it need an RFC?

probinson added inline comments.Nov 6 2018, 8:48 AM
llvm/docs/CommandGuide/FileCheck.rst
28

This currently implies the command line is done first, which it isn't.
"Options are parsed from the env var and then from the command line" or something along those lines.

llvm/utils/FileCheck/FileCheck.cpp
117–118

For arguments such as "" and nullptr, generally the style is to put the parameter name in a comment so the reader knows what is being omitted. So in this case something like:

..., /*Overview*/ "", /*Errs*/ nullptr, "FILECHECK_OPTS");
jdenny added inline comments.Nov 6 2018, 11:59 AM
llvm/docs/CommandGuide/FileCheck.rst
28

Good point. I'll just reverse that. Thanks.

Either way, as you hinted, the order is only implied here. I'm intentionally avoiding being explicit because I know of no FileCheck option where the order of multiple occurrences should matter. The only option I know of for which order does matter is -D: all definitions of a variable after the first are ignored. My guess is that behavior is unintentional and multiply defined variables should be errors instead. I just wrote a quick patch to make them errors, and I see no new test fails from check-all. I'm happy to submit that patch... or to be advised that I need to rethink this issue.

On the other hand, for the (internal) documentation of ParseCommandLineOptions, I was explicit about the order because ParseCommandLineOptions might one day be reused by some other program where this issue needs to be considered.

llvm/utils/FileCheck/FileCheck.cpp
117–118

Thanks. Just out of curiosity, is this style documented somewhere? I'll make the change regardless.

jdenny updated this revision to Diff 172819.Nov 6 2018, 12:03 PM

Address reviewer comments:

  • Add comments for empty-string and nullptr arguments.
  • Don't imply command-line options are parsed before FILECHECK_OPTS.
probinson accepted this revision.Nov 6 2018, 1:06 PM

LGTM.
A patch to report an error on multiple -D of the same variable is probably a good thing, particularly since it doesn't work properly.

llvm/utils/FileCheck/FileCheck.cpp
117–118

Interesting, I thought it was but now that I look, I don't see it in the coding standard. I do see this used in the project and I like it, so at some point I'll probably put up a patch to add it to the docs.

This revision is now accepted and ready to land.Nov 6 2018, 1:06 PM
This revision was automatically updated to reflect the committed changes.
jdenny added a comment.Nov 6 2018, 2:11 PM

LGTM.
A patch to report an error on multiple -D of the same variable is probably a good thing, particularly since it doesn't work properly.

Thanks. I'll polish that up and submit it eventually.