This is an archive of the discontinued LLVM Phabricator instance.

[Attr] Fix paren, comma, and omitted arg printing in some cases
ClosedPublic

Authored by jdenny on Feb 25 2018, 11:27 AM.

Details

Reviewers
aaron.ballman
Summary

The first FIXME introduced here will be addressed in another patch
(https://reviews.llvm.org/D43248).

Diff Detail

Event Timeline

jdenny created this revision.Feb 25 2018, 11:27 AM

In general, I think the idea is reasonable, but in practice I'm worried about the attributes with custom parsing. Sometimes the parsing requires those extra bits and I'm not certain of how best to address that.

test/Misc/ast-print-objectivec.m
52 ↗(On Diff #135836)

This fix is incorrect in this case -- the attribute doesn't parse without the extra commas.

https://godbolt.org/g/Ze69HD

jdenny added inline comments.Feb 25 2018, 12:01 PM
test/Misc/ast-print-objectivec.m
52 ↗(On Diff #135836)

Sorry, I should have researched that one.

It is straight-forward to make it treat an argument as provided based on its argument type. Will look into it soon.

jdenny updated this revision to Diff 135982.Feb 26 2018, 3:04 PM

Aaron: Because the last two arguments for objc_bridge_related must be delimited with commas, this revision takes the view that they are not optional but are permitted to be the empty string.

The test suite behaves as expected. Are there any untested attributes that might be broken by this patch? Hopefully they can be addressed in a similar manner.

jdenny marked 2 inline comments as done.Feb 26 2018, 4:13 PM
aaron.ballman added inline comments.Feb 27 2018, 8:10 AM
test/Sema/attr-print.c
12

Please add a test showing that objc_bridge_related isn't mangled by -ast-print.

utils/TableGen/ClangAttrEmitter.cpp
303–304

I think you can remove this case and the TypeSourceInfo * as well and just rely on returning "false" in those cases.

jdenny added inline comments.Feb 27 2018, 8:16 AM
test/Sema/attr-print.c
12

There's already one in Misc/ast-print-objectivec.m, but I can add one here too if that's helpful.

aaron.ballman added inline comments.Feb 27 2018, 8:23 AM
test/Sema/attr-print.c
12

Nope, not necessary -- it's already got the coverage I was hoping for. Thank you!

jdenny updated this revision to Diff 136136.Feb 27 2018, 1:01 PM
jdenny edited the summary of this revision. (Show Details)

This addresses the comment about redundant ifs.

jdenny marked 4 inline comments as done.Feb 27 2018, 1:03 PM
aaron.ballman accepted this revision.Feb 27 2018, 2:11 PM

LGTM! I can commit on your behalf, or, if you plan to continue submitting patches, you can ask for commit privileges (http://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access) and commit yourself. Either way works for me.

This revision is now accepted and ready to land.Feb 27 2018, 2:11 PM

LGTM! I can commit on your behalf, or, if you plan to continue submitting patches, you can ask for commit privileges (http://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access) and commit yourself. Either way works for me.

I'll definitely pursue commit privileges. If you don't mind committing anything you accept today, that would be great. Thanks for your help!

aaron.ballman closed this revision.Feb 27 2018, 3:51 PM

Committed in r326266.