[PATCH] D86699: [SyntaxTree] Ignore implicit non-leaf `CXXConstructExpr`
Dmitri Gribenko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 31 12:31:44 PDT 2020
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.
================
Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:48-58
+static Expr *IgnoreImplicitCXXConstructExpr(Expr *E) {
+ if (auto *C = dyn_cast<CXXConstructExpr>(E)) {
+ auto NumArgs = C->getNumArgs();
+ if (NumArgs == 1 || (NumArgs > 1 && isa<CXXDefaultArgExpr>(C->getArg(1)))) {
+ auto *A = C->getArg(0);
+ if (A->getSourceRange() == E->getSourceRange())
+ return A;
----------------
eduucaldas wrote:
> Should this go into `IgnoreExpr` as well?
>
> If yes, should we unify this with the lambda inside `IgnoreUnlessSpelledInSource`, thus removing the lambda and using this free function instead?
That sounds like a good idea to me.
================
Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:1749
void test(X x, X y) {
[[x + y]];
}
----------------
Could you also add a test that invokes implicit conversions?
```
struct X {
X(int);
};
void TakeX(const X&);
void test() {
[[TakeX(1)]];
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D86699/new/
https://reviews.llvm.org/D86699
More information about the cfe-commits
mailing list