Page MenuHomePhabricator

Add handling for DeducedType to HasDeclarationMatcher
ClosedPublic

Authored by fgross on Aug 4 2017, 5:33 AM.

Details

Summary

HasDeclarationMatcher did not handle DeducedType, it always returned false for deduced types.

So with code like this:

struct X{};
auto x = X{};

This did no longer match:

varDecl(hasType(recordDecl(hasName("X"))))

Because HasDeclarationMatcher didn't resolve the DeducedType of x.

This came up because some checks in clang-tidy didn't match as expected anymore.

Diff Detail

Repository
rL LLVM

Event Timeline

fgross created this revision.Aug 4 2017, 5:33 AM
klimek accepted this revision.Aug 4 2017, 6:45 AM

Thanks! LG after comment change.

Also, should we add some tests to clang-tidy? :)

include/clang/ASTMatchers/ASTMatchersInternal.h
745 ↗(On Diff #109715)

I think the behavior doesn't need a comment, but the reason :)

// DeducedType dos not have declarations of its own, so
// match the deduced type instead.
This revision is now accepted and ready to land.Aug 4 2017, 6:45 AM
fgross updated this revision to Diff 109795.Aug 4 2017, 11:56 AM

Changed comment, added some clang-tidy test cases.

fgross marked an inline comment as done.Aug 4 2017, 11:57 AM
This revision was automatically updated to reflect the committed changes.