This is an archive of the discontinued LLVM Phabricator instance.

Add an ASTMatcher for ignoring ExprWithCleanups.
AbandonedPublic

Authored by timshen on Jun 10 2016, 1:53 PM.

Details

Summary

This is part of the fix of clang-tidy patterns to adapt to newly added ExprWithCleanups node.

Diff Detail

Event Timeline

timshen updated this revision to Diff 60398.Jun 10 2016, 1:53 PM
timshen retitled this revision from to Add an ASTMatcher for ignoring ExprWithCleanups..
timshen updated this object.
timshen added a reviewer: rsmith.
timshen added a subscriber: cfe-commits.
rsmith edited reviewers, added: klimek; removed: rsmith.Jun 10 2016, 2:35 PM
rsmith edited subscribers, added: rsmith; removed: klimek.
klimek edited edge metadata.Jun 12 2016, 1:01 PM

Please add a test.

aaron.ballman added a subscriber: aaron.ballman.

Also, please add documentation to the matcher definition and regenerate the documentation.

timshen updated this revision to Diff 60704.Jun 14 2016, 10:33 AM
timshen edited edge metadata.

Done.

aaron.ballman added inline comments.Jun 14 2016, 2:59 PM
include/clang/ASTMatchers/ASTMatchers.h
629

This documentation is used to generate the public docs, so it should include examples with matchers (of what does and does not match). It's especially important because this AST matcher may not be obvious to everyone as to why you'd use it or what it applies to.

633

Should be auto * (possibly const-qualified if you can get away with it).

I was wondering why we didn't created that Matcher: IgnoreImplicit

I believe it's more commonly used than 'ignoringExprWithCleanups'.

It can be implemented by calling 'Stmt.IgnoreImplicit'.

/// Skip past any implicit AST nodes which might surround this
/// statement, such as ExprWithCleanups or ImplicitCastExpr nodes.
Stmt *IgnoreImplicit();
unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
2018

nit: you can lift that expression to a local variable:

varDecl(hasInitializer(ignoringExprWithCleanups(

ignoringParenImpCasts(integerLiteral()))))))

It's used 3 times.

timshen abandoned this revision.Jun 21 2016, 1:31 PM

I was wondering why we didn't created that Matcher: IgnoreImplicit

Actually you are right. There already exists a IgnoreImplict in clang-tidy and I just switched to that.

Abandoning this patch.

Thanks!