This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Remove redundant init-parens in AST print
ClosedPublic

Authored by lichray on Feb 25 2022, 8:56 PM.

Details

Summary

Given a dependent T (maybe an undeduced auto),

Before:

new T(z)  -->  new T((z))  # changes meaning with more args
new T{z}  -->  new T{z}
    T(z)  -->      T(z)
    T{z}  -->      T({z})  # forbidden if T is auto

After:

new T(z)  -->  new T(z)
new T{z}  -->  new T{z}
    T(z)   -->     T(z)
    T{z}   -->     T{z}

Depends on D113393

Diff Detail

Event Timeline

lichray requested review of this revision.Feb 25 2022, 8:56 PM
lichray created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 25 2022, 8:56 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
aaron.ballman accepted this revision.Feb 28 2022, 10:07 AM

LGTM aside from a nit.

clang/lib/AST/StmtPrinter.cpp
2156–2159

You should still spell out the type as it's not spelled out in the initialization.

This revision is now accepted and ready to land.Feb 28 2022, 10:07 AM
lichray added inline comments.Feb 28 2022, 10:19 AM
clang/lib/AST/StmtPrinter.cpp
2156–2159

In this piece of code, I got "CXXNewExpr," "InitializationStyle", "::" -- every morpheme needed to derive the type "CXXNewExpr::InitializationStyle," so I guess it's clear enough.

aaron.ballman added inline comments.Feb 28 2022, 10:23 AM
clang/lib/AST/StmtPrinter.cpp
2156–2159

I don't want to hold anything up over this, but the usual rule of thumb is "in the initialization" so that we don't have to hunt around to other code to figure out the type.

lichray updated this revision to Diff 411843.Feb 28 2022, 10:41 AM
lichray marked 2 inline comments as done.

Nit

This revision was landed with ongoing or failed builds.Feb 28 2022, 5:31 PM
This revision was automatically updated to reflect the committed changes.