This is an archive of the discontinued LLVM Phabricator instance.

[Tooling] Returns non-zero status code when files are skipped.
ClosedPublic

Authored by ioeric on Jan 22 2018, 1:05 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

ioeric created this revision.Jan 22 2018, 1:05 AM
hokein added a subscriber: bkramer.Jan 22 2018, 2:13 AM
hokein added inline comments.
include/clang/Tooling/Tooling.h
331 ↗(On Diff #130840)

I'm not sure whether this new behavior will cause any regression issues (many tools invoke this method like if (Tool.run(...)))

  • before the patch, return 0 if some files are skipped (we think it succeeds)
  • after the patch, return 2 if some files are skipped (we think it fails)

Maybe @bkramer has more words on it?

ioeric added inline comments.Jan 22 2018, 2:24 AM
include/clang/Tooling/Tooling.h
331 ↗(On Diff #130840)

I should have mentioned in the path summary that I think this would not regress tools. I checked call sites of this API. I think it's reasonable for most tools to treat skipping files as failure (if they care about failure; some tools simply ignore the status code). Tools that care about this are already ignoring the failures (e.g. https://github.com/llvm-mirror/clang/blob/master/tools/clang-refactor/ClangRefactor.cpp#L630). But there might be something that I am missing. I would certainly like more opinions on this.

bkramer added inline comments.Jan 22 2018, 4:34 AM
lib/Tooling/Tooling.cpp
404 ↗(On Diff #130840)

This comment explains why the implementation doesn't error. Can you make sure the xargs use case is still working properly?

ioeric added inline comments.Jan 30 2018, 1:14 AM
lib/Tooling/Tooling.cpp
404 ↗(On Diff #130840)

I somehow missed the big FIXME... thanks for the catch!

I don't think this is a very typical use case that should affect design decision here, and I would expect xargs users to do something like xargs tool $@ || true if they really want to ignore errors. WDYT?

bkramer added inline comments.Feb 1 2018, 5:28 AM
lib/Tooling/Tooling.cpp
404 ↗(On Diff #130840)

Yeah. I think the only important thing is that xargs doesn't stop after the first error. But that seems to be the default behavior of xargs?

ioeric added inline comments.Feb 1 2018, 5:42 AM
lib/Tooling/Tooling.cpp
404 ↗(On Diff #130840)

Looks like this is the case, from the manual:

If  any  invocation of the command exits with a status of 255, xargs will stop immediately without reading any further input.  An error message is issued on stderr when this happens.

Should I just remove the FIXME?

bkramer accepted this revision.Feb 2 2018, 9:02 AM

Removing FIXME seems right to me.

This revision is now accepted and ready to land.Feb 2 2018, 9:02 AM
ioeric updated this revision to Diff 132624.Feb 2 2018, 10:19 AM

removed FIXME

This revision was automatically updated to reflect the committed changes.
This revision was automatically updated to reflect the committed changes.