================
@@ -49,7 +49,7 @@ struct RegularException {
// --------------
----------------
zeyi2 wrote:
Sorry that I didn't make it clearer:
The main idea of this is to test a implicitly-defined destructor (inheriting
`std::exception`).
You can verify a implicit used destructor do exist by:
```
$ clang-check -ast-dump repro.cpp | grep "CXXDestructorDecl"
...
| |-CXXDestructorDecl 0x2210e170 <line:4:5, col:24> col:13 used ~exception
'void () noexcept' virtual
| `-CXXDestructorDecl 0x2212d7e8 <col:8> col:8 implicit used ~RegularException
'void () noexcept' inline default
```
I think when `RegularException` inherits from `std::exception`, the temporary
object `RegularException(0)` creates an `ExprWithCleanups` and
`CXXBindTemporaryExpr` node in the AST to handle the destruction.
The new matcher uses `hasParent(stmt(anyOf(..., compoundStmt(), ...)))`, and
the `cxxConstructExpr` is no longer a direct child of `compoundStmt` due to
`ExprWithCleanups` wrapper, leading to a missed match. IMO this may introduce a
regression as the original code caught this by `hasAncestor`:
```
$ clang-query -c "match cxxConstructExpr(hasParent(compoundStmt()))" repro.cpp
--
0 matches.
$ clang-query -c "match cxxConstructExpr(hasAncestor(compoundStmt()))"
repro.cpp --
...
12 | void DestructorTest() { RegularException(0); }
| ^~~~~~~~~~~~~~~~~~~
1 match.
```
You might want to use `traverse(TK_IgnoreUnlessSpelledInSource, ...)` to skip
these implicit nodes.
Please let me know if I misunderstood anything.
https://github.com/llvm/llvm-project/pull/173748
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits