================
@@ -4210,6 +4215,7 @@ class Parser : public CodeCompletionHandler {
   /// \endverbatim
   ExprResult ParseParenExpression(ParenParseOption &ExprType,
                                   bool stopIfCastExpr, bool isTypeCast,
+                                  bool ParenKnownToBeNonCast,
----------------
AaronBallman wrote:

> Actually on that note, TypeCastState is a thing. Can we just merge this 
> parameter with the isTypeCast one and make it a TypeCastState?

`TypeCastState` is cursed in that it doesn't mean what you might think it 
means: 
https://github.com/llvm/llvm-project/commit/77e21fca3cd1a9db882ac13ac5ddef3f278dfff2

So it doesn't mean "this is, is not, or maybe a cast expression", it means "if 
there's a typo, should we allow type names or not?" I verified this is not 
vestigial code after delayed typo correction was removed; it's still used for 
typo correction today. We probably should rename some stuff to make this far 
more clear though, because your suggestion is what I initially tried to 
implement and broke approximately every test in the suite.

> How about introducing a new enumeration here?

Given that there's three bools in a row, yeah, that's not a bad idea.

How about this for a solution:

1) Rename `TypeCastState` to `TypoCorrectionTypeBehavior`
2) Rename `NotTypeCast`, `IsTypeCast`, and `MaybeTypeCast` to `AllowNonTypes, 
`AllowTypes`, and `AllowBoth`
3) Add a new enumeration `TypeCastState` with members `IsTypeCast`, 
`IsNotTypeCast`, and `Unknown`
4) Change `ParseParenExpression` to take both a `TypoCorrectionTypeBehavior` 
and a `TypeCastState`.

WDYT?

https://github.com/llvm/llvm-project/pull/146394
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to