This is a fix for the new ExprWithCleanups introduced by clang's temporary variable lifetime marks change.
Details
- Reviewers
angelgarcia alexfh bkramer sbenza - Commits
- rG325c7274809b: Fix clang-tidy patterns to adapt to newly added ExprWithCleanups nodes.
rCTE273310: Fix clang-tidy patterns to adapt to newly added ExprWithCleanups nodes.
rL273310: Fix clang-tidy patterns to adapt to newly added ExprWithCleanups nodes.
Diff Detail
Event Timeline
Does this just fix the tests broken with D20498 or have you looked at other checks that might be broken by D20498, but don't have relevant tests? In the latter case we'd certainly need your help figuring out where further problems may appear, e.g. what specific patterns should we look for in the AST matchers used in clang-tidy checks or other Clang tools. Does this boil down to expr(X) -> expr(ignoringExprWithCleanups(X))?
Actually, the more interesting question is what patterns in the analyzed code generate ExprWithCleanups?
This just fixes the tests broken by D20498. I didn't look at other patterns.
Actually, the more interesting question is what patterns in the analyzed code generate ExprWithCleanups?
A MaterializeTemporaryExpr now will always generate an ExprWithCleanups at full-expr entry. That is to say, there must be an ExprWithCleanups as an ancestor node of a MaterializeTemporaryExpr.
For example, the previous pattern:
fooStmt(has( barExpr( hasDescendant( materializeTemporaryExpr()))))
should be changed to:
fooStmt(has( exprWithCleanups( barExpr( hasDescendant( materializeTemporaryExpr())))
There are patterns around that are not explicitly checking for a MaterializeTemporaryExpr. If in the checked AST there is a MaterializeTemporaryExpr, an ignoringExprWithCleanups should be added to each of these patterns.
Does this help?
Updated the patch to use ignorngImplicit/Expr::IgnoreImplicit matcher.
I think there is a systematic way to do this change:
Look at every ignoringImpCasts, ignoringParenCasts, ignoringParenImpCasts, ignoringParens, and
Expr::IgnoreImpCasts, Expr::IgnoreParenCasts, Expr::IgnoreParenImpCasts, Expr::IgnoreParens to
see if they can be changed to ignoringImplicit or Expr::IgnoreImplicit (which also ignores
ExprWithCleanups).
I'd say for most of the cases ExprWithCleanups should be ignored, but I'm not sure if I'm the
right person to look at these patterns.
Yes, you're probably not the right person to fix our test coverage. Thanks for fixing the stuff that broke and I hope we'll figure out what else needs to be fixed in a finite time after the change is committed ;)
LG