This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] CloneDetector now checks template arguments of function calls.
ClosedPublic

Authored by teemperor on Aug 16 2016, 6:58 AM.

Details

Summary

The CloneDetector currently ignores template arguments in function calls which leads to false-positive clones such as isa<Expr>(S) and isa<Stmt>(S).

This patch adds functionality to handle template arguments for those function calls.

Diff Detail

Repository
rL LLVM

Event Timeline

teemperor updated this revision to Diff 68173.Aug 16 2016, 6:58 AM
teemperor retitled this revision from to [analyzer] CloneDetector now checks template arguments of function calls..
teemperor updated this object.
teemperor added reviewers: v.g.vassilev, NoQ.
teemperor added a subscriber: cfe-commits.
NoQ added inline comments.Aug 16 2016, 12:25 PM
lib/Analysis/CloneDetection.cpp
154 ↗(On Diff #68173)

Maybe if (const FunctionDecl *D = S->getDirectCallee()) here, and then use D everywhere inside the if?

164 ↗(On Diff #68173)

We don't discriminate between foo<A, AA>() and foo<AA, A>() here, because in both cases the stuff we hash gets concatenated to AAA. Just thought that we might be having this common problem everywhere, even though it barely shows up "in real life".

test/Analysis/copypaste/call.cpp
41 ↗(On Diff #68173)

"temp" feels a lot more like "temporary" than like "template" (?)

v.g.vassilev accepted this revision.Aug 17 2016, 7:38 AM
v.g.vassilev edited edge metadata.

LGTM once the @NoQ remarks are addressed.

This revision is now accepted and ready to land.Aug 17 2016, 7:38 AM
teemperor marked 3 inline comments as done.Aug 19 2016, 7:18 AM
teemperor added inline comments.
lib/Analysis/CloneDetection.cpp
164 ↗(On Diff #68173)

Yes, that could be a problem. I'll fix this issue here in this patch and the others in another patch.

teemperor updated this revision to Diff 68683.Aug 19 2016, 7:18 AM
teemperor edited edge metadata.
teemperor marked an inline comment as done.
This revision was automatically updated to reflect the committed changes.