This is an archive of the discontinued LLVM Phabricator instance.

Fix printing of types in initializers with suppressed tags.
ClosedPublic

Authored by nick.sumner on Jan 21 2016, 6:23 PM.

Details

Summary

Tag and specifier printing can be suppressed in Decl::printGroup, but these suppressions leak into the initializers. Thus

int *x = ((void *)0), *y = ((void *)0);

gets printed as

int *x = ((void *)0), *y = ((*)0);

And

struct { struct Z z; } z = {(struct Z){}};

gets printed as

struct { struct Z z; } z = {(){}};

The stops the suppressions from leaking into the initializers.

Diff Detail

Event Timeline

nick.sumner retitled this revision from to Fix printing of nested variable declarations with suppressed tags.
nick.sumner updated this object.
nick.sumner added reviewers: bkramer, rsmith.
nick.sumner added a subscriber: cfe-commits.
rsmith added inline comments.Jan 21 2016, 11:19 PM
lib/AST/StmtPrinter.cpp
132 ↗(On Diff #45634)

Maybe we should instead do this whenever we start printing a variable's initializer? I don't think your patch will fix the same bug in this case:

struct X {};
struct { int n; } x = { [](struct X *x) { return 0; }(0) };
nick.sumner retitled this revision from Fix printing of nested variable declarations with suppressed tags to Fix printing of types in initializers with suppressed tags..
nick.sumner updated this object.

Updated to reset tag and specifier suppression precisely when printing initializers.

rsmith accepted this revision.Jan 23 2016, 1:09 PM
rsmith edited edge metadata.

LGTM, thanks! Do you have SVN commit access?

This revision is now accepted and ready to land.Jan 23 2016, 1:09 PM

Thanks for your help!

I don't have SVN commit access.

This revision was automatically updated to reflect the committed changes.