This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Proper caching in CallDescription objects.
ClosedPublic

Authored by xazax.hun on Feb 13 2017, 1:22 AM.

Details

Summary

During the review of https://reviews.llvm.org/D29567 it turned out the caching in CallDescription is not implemented properly. In case an identifier does not exist in a translation unit, repeated identifier lookups will be done which might have bad impact on the performance. This patch guarantees that the lookup is only executed once. Moreover this patch fixes a corner case when the identifier of CallDescription does not exist in the translation unit and the called function does not have an identifier (e.g.: overloaded operator in C++).

Diff Detail

Repository
rL LLVM

Event Timeline

xazax.hun created this revision.Feb 13 2017, 1:22 AM
szepet removed a reviewer: szepet.Feb 13 2017, 1:43 AM
szepet added a subscriber: szepet.
NoQ accepted this revision.Feb 15 2017, 7:14 AM

Yep, seems that somebody has missed these issues :)

I guess there's no way to test the operator case, because nobody made a CallDescription with an empty name for us (maybe we should even assert that).

This revision is now accepted and ready to land.Feb 15 2017, 7:14 AM
This revision was automatically updated to reflect the committed changes.
In D29884#677387, @NoQ wrote:

Yep, seems that somebody has missed these issues :)

I guess there's no way to test the operator case, because nobody made a CallDescription with an empty name for us (maybe we should even assert that).

Thank you for the review! :) Unfortunately, I did not get where would you put that assert. But in case you think it is important, I would be happy to review a patch :)

NoQ added inline comments.Feb 15 2017, 8:17 AM
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
73

Maybe assert(FuncName.size() > 0) here?

xazax.hun added inline comments.Feb 15 2017, 8:19 AM
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
73

Oh, I see now. Yeah, that would make sense :) Do you want me to commit that or will you?

NoQ added inline comments.Feb 15 2017, 8:36 AM
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
73

Because C++ checkers are receiving a lot of attention recently, i'd probably be looking into modifying this class to work with qualified names and overloads. You can commit though if you want it sooner :)