This is an archive of the discontinued LLVM Phabricator instance.

Clean up 'target' attribute diagnostics
ClosedPublic

Authored by erichkeane on Feb 15 2018, 3:23 PM.

Details

Summary

There were a few issues previously with the target
attribute diagnostics implementation that lead to the
attribute being added to the AST despite having an error
in it.

This patch changes that, and adds a test to ensure it
does not get added to the AST.

Diff Detail

Repository
rC Clang

Event Timeline

erichkeane created this revision.Feb 15 2018, 3:23 PM
echristo accepted this revision.Feb 15 2018, 3:26 PM

Seems ok here.

This revision is now accepted and ready to land.Feb 15 2018, 3:26 PM

Thanks! I'll give @aaron.ballman a chance to take a look, so I'll probably do something about this tomorrow.

aaron.ballman added inline comments.Feb 16 2018, 5:50 AM
test/Sema/attr-target-ast.c
2

Can you drop the svn props from this file?

test/Sema/attr-target.c
4–5

Is there ever a case where you *won't* get the "ignoring unsupported" without also getting the "'target' attribute ignored" warning as well? It seems a bit chatty to give two diagnostics for each mistake, and it makes one of those diagnostics seem incorrect -- in this case, one diagnostic says "ignoring unsupported architecture 'hiss'", implying the others are not ignored, but then the second diagnostic says the whole attribute is ignored.

erichkeane added inline comments.Feb 16 2018, 8:37 AM
test/Sema/attr-target-ast.c
2

Absolutely, I'll do that on commit.

test/Sema/attr-target.c
4–5

There is not... I actually put in the second because I thought that the 1st (ignoring unsupported...) was pretty ambiguous. I'll rev this patch seeing if I can simply make the former more clear.

aaron.ballman added inline comments.Feb 16 2018, 8:42 AM
test/Sema/attr-target.c
4–5

I think that makes sense. Or, alternatively, make the first diagnostic accurate by dropping all unsupported targets (leaving the valid ones) and adjusting the diagnostic wording depending on whether the whole attribute is dropped, or just parts of it?

Do as @aaron.ballman suggested for the message. Also, removed properties from the new file.

aaron.ballman accepted this revision.Feb 16 2018, 9:25 AM

Aside from a minor wording nit, LGTM!

include/clang/Basic/DiagnosticSemaKinds.td
2448–2450

Can you manually quote 'target' in the diagnostic? I know it wasn't there before, but we try to stick quotes around syntactic constructs.

This revision was automatically updated to reflect the committed changes.