This is an archive of the discontinued LLVM Phabricator instance.

Fix bug in DynTypedMatcher::constructVariadic() that would cause false negatives.
ClosedPublic

Authored by sbenza on Oct 2 2014, 8:18 AM.

Details

Summary

DynTypedMatcher::constructVariadic() where the restrict kind of the
different matchers are not related causes the matcher to have a "None"
restrict kind. This causes false negatives for anyOf and eachOf.
Change the logic to get a common ancestor if there is one.
Also added regression tests that fail without the fix.

Diff Detail

Repository
rL LLVM

Event Timeline

sbenza updated this revision to Diff 14326.Oct 2 2014, 8:18 AM
sbenza retitled this revision from to Fix bug in DynTypedMatcher::constructVariadic() that would cause false negatives..
sbenza updated this object.
sbenza edited the test plan for this revision. (Show Details)
sbenza added a reviewer: klimek.
sbenza added a subscriber: Unknown Object (MLST).
klimek edited edge metadata.Oct 3 2014, 6:22 AM

Overall, I think Anything and Nothing are not intuitive names for me here... Perhaps more docs will make it clear what they should be called.

include/clang/AST/ASTTypeTraits.h
94–98 ↗(On Diff #14326)

a) why return anything()? (document the decisions, seems kinda arbitrary)
b) typo: Ancestor

105–106 ↗(On Diff #14326)

Can you document what Nothing and Anything is in NodeKind land, and document that?

lib/AST/ASTTypeTraits.cpp
23–32 ↗(On Diff #14326)

I just realize this all might need some documentation.

unittests/ASTMatchers/Dynamic/RegistryTest.cpp
350 ↗(On Diff #14326)

Is this test change related?

sbenza updated this revision to Diff 14376.Oct 3 2014, 7:01 AM
sbenza edited edge metadata.

Remove anything(). It is not needed for this fix.

sbenza updated this object.Oct 3 2014, 7:03 AM
sbenza added a comment.Oct 3 2014, 7:06 AM

Reverted a lot of the change.
Please review against the base.

include/clang/AST/ASTTypeTraits.h
94–98 ↗(On Diff #14326)

Removed the concept of 'anything'. was not necessary and the name was not correct.
Fixed the typo everywhere (I think).

105–106 ↗(On Diff #14326)

Reverted this.

lib/AST/ASTTypeTraits.cpp
23–32 ↗(On Diff #14326)

Reverted this.

unittests/ASTMatchers/Dynamic/RegistryTest.cpp
350 ↗(On Diff #14326)

Yes. The change triggered the bug.
recordDecl is a namedDecl, so it wasn't hitting the bug. I made it more specific with functionDecl and it started failing. The fix made it pass again.

klimek accepted this revision.Oct 6 2014, 1:24 AM
klimek edited edge metadata.

lg

This revision is now accepted and ready to land.Oct 6 2014, 1:24 AM
sbenza closed this revision.Oct 6 2014, 6:25 AM
sbenza updated this revision to Diff 14451.

Closed by commit rL219118 (authored by @sbenza).