This is an archive of the discontinued LLVM Phabricator instance.

[clang][driver] Enable MisExpect diagnostics flag outside of CC1
ClosedPublic

Authored by paulkirth on Apr 25 2023, 2:34 PM.

Details

Summary

Previously we only accepted the -fdiagnostics-misexpect-tolerance= at
CC1, when it should have been handled identically to
-fdiagnostics-hotness-threshold=. It should not have been required to
pass this flag w/ -Xclang as reported here:
https://reviews.llvm.org/D115907#inline-1440745

Diff Detail

Event Timeline

paulkirth created this revision.Apr 25 2023, 2:34 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 25 2023, 2:34 PM
paulkirth requested review of this revision.Apr 25 2023, 2:34 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 25 2023, 2:34 PM
paulkirth retitled this revision from [clang][driver] Enable MisExpect diagnostics flag outside of CC! to [clang][driver] Enable MisExpect diagnostics flag outside of CC1.Apr 25 2023, 4:32 PM
phosek accepted this revision.Apr 26 2023, 12:35 AM

LGTM

This revision is now accepted and ready to land.Apr 26 2023, 12:35 AM
hans added inline comments.Apr 26 2023, 6:37 AM
clang/test/Profile/misexpect-branch.c
10 ↗(On Diff #516922)

The more common way to test this would be a test under clang/test/Driver/ that just checks that forwarding the flag works.

paulkirth added inline comments.Apr 26 2023, 8:29 AM
clang/test/Profile/misexpect-branch.c
10 ↗(On Diff #516922)

Good point, I just defaulted to adding the RUN line here, but that's definitely the right way to test this.

paulkirth updated this revision to Diff 517199.Apr 26 2023, 8:54 AM

Migrate to a Driver test

hans added inline comments.Apr 26 2023, 9:59 AM
clang/test/Driver/clang_f_opts.c
144

Instead of checking for absence of the warning, could we just check that the flag is present among the cc1 flags? I think that's how most of the other tests here do it.

paulkirth marked an inline comment as done.

Update test to check if the flag is in cc1, instead of just looking for a warning.

clang/test/Driver/clang_f_opts.c
144

It took me a minute to realize what you meant here. I was pretty surprised to find out that "-fdiagnostics-misexpect-tolerance=10" is how we test for cc1, but '-fdiagnostics-misexpect-tolerance=' is a test for an error/warning string. The reason I wrote the check this way was so that I wouldn't accidentally match on the non-warning case.

TBH Ithink checking the cc1 flags like this is pretty brittle. They would all silently pass (even when they shouldn't) if the warning diagnostic used " instead of '. I'm sure some other tests would fail/need to be changed in that case, but there wouldn't be any indication that these tests wouldn't be functioning as intended.

hans accepted this revision.Apr 27 2023, 5:51 AM

lgtm

This revision was landed with ongoing or failed builds.Apr 27 2023, 2:20 PM
This revision was automatically updated to reflect the committed changes.