This is an archive of the discontinued LLVM Phabricator instance.

Parse a possible trailing postfix expression suffix after a fold expression
ClosedPublic

Authored by Rakete1111 on Jul 26 2018, 5:36 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

Rakete1111 created this revision.Jul 26 2018, 5:36 AM
Rakete1111 retitled this revision from Parse a possible trailing postsfix expression suffix after a fold expression to Parse a possible trailing postfix expression suffix after a fold expression.Jul 26 2018, 5:37 AM

Shouldn't the caller of ParseParenExpression already be doing this?

@rsmith you're right, it should. But it doesn't, because the the fold expression is considered to be a cast expression by ParseParenExpression and which parses any postfix pieces immediately after a cast, but it doesn't do so for fold expression, because they don't (not surprisingly) involve a cast.

I've added a new type of ParenParseOption for fold-expressions for this, which makes the patch way more cleaner :) (I didn't want to reuse SimpleExpr for fold expressions - conflicts with the docs for it)

Add a test without any casts.

Thanks, I like this approach a lot more.

include/clang/Parse/Parser.h
1658 ↗(On Diff #157580)

This should be reordered up nearer the top (probably as the second enumerator); when we call ParseParenExpression with ExprType == CastExpr or ExprType == CompoundLiteral, we still want to parse FoldExprs.

lib/Parse/ParseExpr.cpp
2519–2563 ↗(On Diff #157580)

The cases where we parse a fold-expression should all be guarded by ExprType >= FoldExpr.

Addressed review comments :)

rsmith accepted this revision.Jul 27 2018, 2:00 PM
This revision is now accepted and ready to land.Jul 27 2018, 2:00 PM
This revision was automatically updated to reflect the committed changes.