Page MenuHomePhabricator

[analyzer] NFC: Change evalCall() to provide a CallEvent.
AcceptedPublic

Authored by NoQ on Fri, May 24, 7:45 PM.

Details

Summary

This is mostly motivated by me being annoyed that in C many functions are implemented as builtins and everybody keeps forgetting about it while writing checkers, leading to checkers not working at all except on LIT tests, which is fairly hard to notice. For that reason i'd like to put a bit more effort into the CallDescription interface, so that to de-duplicate as much code as possible so that nobody needed to remember things.

This is also a necessary step if we want to evalCall() calls that don't correspond to any CallExpr, such as automatic destructor calls.

This patch does varied amount of refactoring in different checkers while updating them after the API breakage. For instance, ChrootChecker is completely converted to CallDescriptions, but CStringChecker is waiting for a few more updates to the CallDescription interface before it can be converted.

Diff Detail

Event Timeline

NoQ created this revision.Fri, May 24, 7:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptFri, May 24, 7:45 PM
NoQ edited the summary of this revision. (Show Details)Fri, May 24, 7:48 PM
NoQ edited the summary of this revision. (Show Details)
a_sidorin accepted this revision.Sun, May 26, 11:11 AM
a_sidorin added inline comments.
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
372

Should we create helpers similar to getDecl() and getOriginExpr (getFunctionDecl/getCallExpr)?

This revision is now accepted and ready to land.Sun, May 26, 11:11 AM
NoQ marked an inline comment as done.Tue, May 28, 4:31 PM
NoQ added inline comments.
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
372

Generally it sounds like a good idea, but in the context of this patch it's only useful when i don't want to refactor the code to avoid needing such getters in the first place. Once the CallDescription interface is good enough, all such getters will turn into hard casts without null checks. But these two checkers implement their own custom call description facility, so they need this sort of dancing.