This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Handle Error message to output proper Prefix
Needs RevisionPublic

Authored by Unique_Usman on Apr 17 2023, 7:59 PM.

Details

Summary

Made err_verify_no_directives output error message to be generic.
The error output is alway default message for all value of -verify which
"no expected directives found: consider use of 'expected-no-diagnostics'"

Now, if you have -verify=foo, the error message will
"no expected directives found: consider use of 'foo-no-diagnostics'"

Resolves issue #58290

Diff Detail

Event Timeline

Unique_Usman created this revision.Apr 17 2023, 7:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 17 2023, 7:59 PM
Unique_Usman requested review of this revision.Apr 17 2023, 7:59 PM
tbaeder edited reviewers, added: aaron.ballman; removed: Aaron1011.Apr 18 2023, 9:14 PM
tbaeder set the repository for this revision to rG LLVM Github Monorepo.
Herald added a project: Restricted Project. · View Herald TranscriptApr 18 2023, 9:14 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

I am not 100% sure about the semantics of passing multiple prefixes, i.e. if the error is emitted for all prefixes individually or if it's only emitted if no expected line for any of the prefixes is found. In the latter case we should probably add all the prefixes to the error message.

clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
1097

Can move this line inside the if statement block.

I am not 100% sure about the semantics of passing multiple prefixes, i.e. if the error is emitted for all prefixes individually or if it's only emitted if no expected line for any of the prefixes is found. In the latter case we should probably add all the prefixes to the error message.

I tested different scenerios e.g added more than one RUN lines with different value of -verify, what I concluded on is that if we have multiple RUN lines with each of them having no directive, the prefixes generated is always of the first occurence with no expected directive so, the error is always generated for the first occurence with no expected directive.

I am not 100% sure about the semantics of passing multiple prefixes, i.e. if the error is emitted for all prefixes individually or if it's only emitted if no expected line for any of the prefixes is found. In the latter case we should probably add all the prefixes to the error message.

I tested different scenerios e.g added more than one RUN lines with different value of -verify, what I concluded on is that if we have multiple RUN lines with each of them having no directive, the prefixes generated is always of the first occurence with no expected directive so, the error is always generated for the first occurence with no expected directive.

Yeah but I think you can do -verify=foo,bar(?) in which case the list f prefixes would actually have more than one item.

I am not 100% sure about the semantics of passing multiple prefixes, i.e. if the error is emitted for all prefixes individually or if it's only emitted if no expected line for any of the prefixes is found. In the latter case we should probably add all the prefixes to the error message.

I tested different scenerios e.g added more than one RUN lines with different value of -verify, what I concluded on is that if we have multiple RUN lines with each of them having no directive, the prefixes generated is always of the first occurence with no expected directive so, the error is always generated for the first occurence with no expected directive.

Yeah but I think you can do -verify=foo,bar(?) in which case the list f prefixes would actually have more than one item.

I used -verify=foo,bar but, the prefixes still have just only one item, in the case bar. Does this the implementation of getting the prefixes is faulty?

tbaeder set the repository for this revision to rG LLVM Github Monorepo.
lattner resigned from this revision.Apr 26 2023, 10:57 AM
tbaeder accepted this revision.Apr 26 2023, 10:20 PM

When I run with -verify=foo,barI only get the output for bar-no-diagnostics. Adding bar-no-diagnostics, I get no output at all and the test succeeds.

I didn't know how passing multiple prefixes works in practice, seems like it matches any of the given ones. So the new output is still better than the old one.

LGTM but I'll wait a while for someone else to chime in.

In the meantime, please state a name and email address to use for the git commit, in case you don't have commit access.

This revision is now accepted and ready to land.Apr 26 2023, 10:20 PM

Thanks @tbaeder, I really appreciate your time.

Name is Unique_Usman and my email is usmanakinyemi202@gmail.com

As you mentioned, if anyone later chime in, I will be glad to update the issue back.
Thank you.

aaron.ballman requested changes to this revision.Apr 27 2023, 7:00 AM

Thank you for working on this! These changes should come with test coverage (we have a handful of verifier tests in clang/test/Frontend -- you can add a new test file there), but I don't think a release note is required because this is a fix for internal functionality. The test should cover the simple case of -verify=something as well as a more complex test with -verify=something, something_else.

clang/include/clang/Basic/DiagnosticFrontendKinds.td
175–176

Should we be handling this situation at the same time, as it's effectively the same concern? e.g., https://godbolt.org/z/4Mn1rW9oa

This revision now requires changes to proceed.Apr 27 2023, 7:00 AM

Thank you for working on this! These changes should come with test coverage (we have a handful of verifier tests in clang/test/Frontend -- you can add a new test file there), but I don't think a release note is required because this is a fix for internal functionality. The test should cover the simple case of -verify=something as well as a more complex test with -verify=something, something_else.

Thank you, will work on this.

Thank you for working on this! These changes should come with test coverage (we have a handful of verifier tests in clang/test/Frontend -- you can add a new test file there), but I don't think a release note is required because this is a fix for internal functionality. The test should cover the simple case of -verify=something as well as a more complex test with -verify=something, something_else.

Hello, I have been going through the other verfiier test, so basicallhy the new test file will test if the error output generated by -verify=something and -verify=something, something_else is the expected output right?

clang/include/clang/Basic/DiagnosticFrontendKinds.td
175–176

Hello, do you meant if we should handle when value is passed to -verify and when it is not together?

I will say yes, the solution handle the situation whenever the value is passed to verify and at the same time was able to handle whenever value is not passed(it output the default which is 'expected-no-diagnostics',).

Do you think otherwise?