This is an archive of the discontinued LLVM Phabricator instance.

[Driver] Report available language standards on user error
ClosedPublic

Authored by idlecode on Feb 8 2017, 11:21 AM.

Details

Reviewers
pcc
rsmith
Summary

In case user did not provide valid standard name for -std option,
available values (with short description) will be reported.

To test: clang -std=iso3103 -c source.c

Diff Detail

Event Timeline

idlecode created this revision.Feb 8 2017, 11:21 AM

Test case?

lib/Frontend/CompilerInvocation.cpp
1759

Is it possible to change the diagnostic so that it's easier to tell which part is the supported value and which part is the description?

The diagnostic looks like this, and I found it a little hard to tell at a quick glance:

"c89 - ISO C 1990"

idlecode updated this revision to Diff 88029.Feb 10 2017, 11:42 AM

Added test, changed printout style a bit (but this still needs to be checked)

Indeed, thanks :)
I ran make check-all and had no errors so I thought there are no tests.

lib/Frontend/CompilerInvocation.cpp
1759

Sure, I have tried few formats with quotes/colons but how about this (a bit verbose) version:

note: supported values are:
note: 'c89' for standard 'ISO C 1990'
note: 'c90' for standard 'ISO C 1990'
note: 'iso9899:1990' for standard 'ISO C 1990'
...

What do you think about it? Do you have any suggestions?

rsmith added inline comments.Feb 10 2017, 1:37 PM
include/clang/Basic/DiagnosticDriverKinds.td
233

Please remove this note and instead add "use " to the start of the next note. (That is more consistent with how we add notes to other diagnostics.)

lib/Frontend/CompilerInvocation.cpp
1759

We should probably suppress the notes for standards that aren't applicable to the current language.

idlecode marked 2 inline comments as done.Feb 11 2017, 10:18 AM
idlecode updated this revision to Diff 88100.Feb 11 2017, 11:23 AM

Displayed standards will now match processed file kind

rsmith accepted this revision.Feb 11 2017, 12:10 PM
rsmith added inline comments.
lib/Frontend/CompilerInvocation.cpp
1753–1754

{ on previous line, please, and indent the previous two lines to match the (.

This revision is now accepted and ready to land.Feb 11 2017, 12:10 PM
idlecode updated this revision to Diff 88101.Feb 11 2017, 12:53 PM
idlecode marked an inline comment as done.

Addressed Richard's inline comment.

LGTM, do you need someone to commit for you?

Yes, please.
Thanks for you time :)

Committed as r295113.

idlecode closed this revision.Feb 16 2017, 6:17 AM

Committed as r295113