This is an archive of the discontinued LLVM Phabricator instance.

Fix reported range of partial token replacement
ClosedPublic

Authored by steveire on Aug 23 2018, 3:45 PM.

Diff Detail

Event Timeline

steveire created this revision.Aug 23 2018, 3:45 PM
steveire updated this revision to Diff 162288.Aug 23 2018, 3:48 PM

Fix reported range of partial token replacement

steveire updated this revision to Diff 163447.Aug 30 2018, 4:35 PM

Move comment

I think the fix generally looks good, but can you please add some test coverage for the change?

How? This is 'private' code. I don't think it's worth changing that or creating a test with a huge amount of infrastructure in order to test this indirectly.

Am I missing something?

How? This is 'private' code. I don't think it's worth changing that or creating a test with a huge amount of infrastructure in order to test this indirectly.

This is changing the observable behavior of the tool, so it should have tests unless they're impossible to write.

Am I missing something?

I'd probably pipe the diagnostic output to a temporary file that gets FileChecked with strict whitespace to see if the underlines from the diagnostic match the expected locations. We do this in a few Clang tests, like SemaCXX\struct-class-redecl.cpp or Misc\wrong-encoding.c.

How? This is 'private' code. I don't think it's worth changing that or creating a test with a huge amount of infrastructure in order to test this indirectly.

This is changing the observable behavior of the tool, so it should have tests unless they're impossible to write.

Yes. The current behavior is not tested. I agree that tests are better than no tests.

Am I missing something?

I'd probably pipe the diagnostic output to a temporary file that gets FileChecked with strict whitespace to see if the underlines from the diagnostic match the expected locations. We do this in a few Clang tests, like SemaCXX\struct-class-redecl.cpp or Misc\wrong-encoding.c.

Doesn't this require building-in a new check to clang-tidy which exists only for the purpose of the test? Otherwise how would a test similar to SemaCXX\struct-class-redecl.cpp work? What would be in the RUN line?

I'd probably pipe the diagnostic output to a temporary file that gets FileChecked with strict whitespace to see if the underlines from the diagnostic match the expected locations. We do this in a few Clang tests, like SemaCXX\struct-class-redecl.cpp or Misc\wrong-encoding.c.

Doesn't this require building-in a new check to clang-tidy which exists only for the purpose of the test? Otherwise how would a test similar to SemaCXX\struct-class-redecl.cpp work? What would be in the RUN line?

Oh, I had the impression that this was changing the behavior of existing checks in the tree as well, and that we'd have an existing clang-tidy check that exhibits the problematic behavior. Is that not the case?

As far as I know, no existing clang-tidy checks are affected. I discovered this while implementing a custom check. See https://bugs.llvm.org/show_bug.cgi?id=38678

By the way, is there some keyword I should use in commit messages to link to bugs properly?

aaron.ballman accepted this revision.Sep 6 2018, 12:59 PM

As far as I know, no existing clang-tidy checks are affected. I discovered this while implementing a custom check. See https://bugs.llvm.org/show_bug.cgi?id=38678

It's unfortunate this is going in without tests, but it still LGTM.

By the way, is there some keyword I should use in commit messages to link to bugs properly?

Add the following to the end of the commit message and I believe it will automatically close the Phab review:

Differential Revision: <URL>

Where the URL is the URL to this review.

This revision is now accepted and ready to land.Sep 6 2018, 12:59 PM

Thanks.

The arc tool already inserted Differential Revision: into my git commit, but that's not what I wonder about. I'm looking for something I can insert into my git commit so that the bug will automatically be closed when I commit (and so that the bug will get a link to this PR when the PR is created). Does such a thing exist here?

Thanks.

The arc tool already inserted Differential Revision: into my git commit, but that's not what I wonder about. I'm looking for something I can insert into my git commit so that the bug will automatically be closed when I commit (and so that the bug will get a link to this PR when the PR is created). Does such a thing exist here?

Ah, sorry for the misunderstanding. I don't think such a thing exists here, unfortunately.

This revision was automatically updated to reflect the committed changes.