fogsong233 wrote:

> > What do you think about this approach?
> 
> Makes sense to me. Could be harder than expected but let's try it out.

@vgvassilev 
Glad to hear it makes sense! It might be a bit more nuanced than it looks, but 
I've pushed a commit with the necessary changes—could you take a look?

Regarding a separate optimization: I think we could simplify 
`isCXXDeclarationStatement` by reusing the logic in `isCXXSimpleDeclaration`. 
Specifically, we could remove the top-level switch tand reuse the 
TPResult::Error case in `isCXXSimpleDeclaration`:
```C++
// In case of an error, let the declaration parsing code handle it.
if (TPR == TPResult::Error)
    return true;
```
In this scenario, if we encounter an expression like if or for, 
`isCXXSimpleDeclaration` would treat it as an error and default to treating it 
as a declaration. However, when `isCXXDeclarationStatement` is called with 
`DisambiguatingWithExpression=true`, we could instead treat it as an expression.

While this might be slightly outside the scope of the current issue, I think 
it’s worth considering for a cleaner implementation. What do you think, or we 
can open another PR?

https://github.com/llvm/llvm-project/pull/178842
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to