[PATCH] D81019: Syntax tree: ignore implicit expressions at the top level of statements
Dmitri Gribenko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 3 02:10:15 PDT 2020
gribozavr2 added inline comments.
================
Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:1048
+ syntax::Tree *ChildNode;
+ if (Expr *ChildExpr = dyn_cast<Expr>(Child)) {
+ // This is an expression in a statement position, consume the trailing
----------------
eduucaldas wrote:
> I thought this treatement of derived class should be done by RecursiveASTVisitor
> This is kinda the task of WalkUpFrom*, unfortunately WalkUpFromThis follows the order:
> WalkUpFromBase;
> VisitThis;
>
> And we would've wanted the opposite order:
> VisitThis
> WalkUpFromBase
>
Unfortunately I don't see how to implement this behavior (cheaply) in the visitation methods of RecursiveASTVisitor. The crux of the issue is that we are inserting a syntax tree node (ExpressionStatement) that does not correspond to any semantic AST node. We want to do it for every Expr that appears in a Stmt position -- so we need to know the parent node, or in this case, more precisely, that this Expr node is in a Stmt position.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81019/new/
https://reviews.llvm.org/D81019
More information about the cfe-commits
mailing list