This is an archive of the discontinued LLVM Phabricator instance.

[ASTMatchers] Upgrading typedef matching to c++11
ClosedPublic

Authored by courbet on Apr 14 2016, 7:01 AM.

Details

Reviewers
aaron.ballman
Summary
  • hasType() should be able to match the types of TypedefAliasDecl in addition to TypedefDecl, so made it work on TypedefNameDecl.
  • new typedefNameDecl() matcher, which should be mostly used in place of typedefDecl (most people will want to match any typedef names, and not just those introduces through pre-c++11 typedefs).
  • new typeAliasDecl() matcher, to match only the type alias syntax.

Diff Detail

Event Timeline

courbet updated this revision to Diff 53703.Apr 14 2016, 7:01 AM
courbet retitled this revision from to [ASTMatchers] Upgrading typedef matching to c++11.
courbet updated this object.
courbet added a subscriber: cfe-commits.
aaron.ballman added a subscriber: aaron.ballman.

If we're going to add this (which I think is a good idea), perhaps we should also add typeAliasDecl() at the same time?

unittests/ASTMatchers/ASTMatchersTest.cpp
5417

Can you add a test that ensures the typedef decl matcher does not match a type alias (and vice versa)?

courbet updated this revision to Diff 53724.Apr 14 2016, 8:03 AM
courbet updated this object.
courbet marked an inline comment as done.

Added typeAliasDecl. More tests.

If we're going to add this (which I think is a good idea), perhaps we should also add typeAliasDecl() at the same time?

Makes sense, done.

Example of where this is useful as a drop-in replacement for typedefDecl():

http://reviews.llvm.org/D19117

aaron.ballman edited edge metadata.Apr 14 2016, 8:28 AM

A few minor nits remain.

Please run clang\docs\tools\dump_ast_matchers.py to regenerate the AST matcher documentation with your changes.

unittests/ASTMatchers/ASTMatchersTest.cpp
5420

Should be EXPECT_TRUE with notMatches().

5427

Should be EXPECT_TRUE with notMatches

courbet updated this revision to Diff 53732.Apr 14 2016, 8:38 AM
courbet edited edge metadata.
courbet marked 2 inline comments as done.

Regenerate doc, cosmetics.

aaron.ballman accepted this revision.Apr 14 2016, 8:40 AM
aaron.ballman edited edge metadata.

LGTM, thank you for working on this!

This revision is now accepted and ready to land.Apr 14 2016, 8:40 AM

Thanks for the review ! I don't have write access, could you please submit this for me ?

aaron.ballman closed this revision.Apr 14 2016, 9:11 AM

Committed in r266331