[PATCH] D82278: Fix traversal over CXXConstructExpr in Syntactic mode

Yitzhak Mandelbaum via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 7 13:02:17 PDT 2020


ymandel added a comment.

Thanks for this fix!



================
Comment at: clang/lib/AST/Expr.cpp:3001
         Expr *A = C->getArg(0);
-        if (A->getSourceRange() == SR || !isa<CXXTemporaryObjectExpr>(C))
+        if (A->getSourceRange() == SR || C->isElidable()) {
           E = A;
----------------
aaron.ballman wrote:
> Looks like the change introduced new curly braces for a single-line if.
Why is it necessary to check isElidable?  I think the logic here is subtle (since the AST doesn't explicitly tag implicit expressions), so please add an explanatory comment.


================
Comment at: clang/lib/AST/ParentMapContext.cpp:163
       if (const auto *C = dyn_cast<CXXConstructExpr>(E)) {
-        if (C->getSourceRange() == SR || !isa<CXXTemporaryObjectExpr>(C))
+        if (C->getSourceRange() == SR || C->isElidable())
           return true;
----------------
Same here. Please comment on the logic.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82278/new/

https://reviews.llvm.org/D82278





More information about the cfe-commits mailing list