Page MenuHomePhabricator

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

Authored by NoQ on May 24 2019, 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

Repository
rL LLVM

Event Timeline

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

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

This revision is now accepted and ready to land.May 26 2019, 11:11 AM
NoQ marked an inline comment as done.May 28 2019, 4:31 PM
NoQ added inline comments.
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
372 ↗(On Diff #201380)

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.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJun 19 2019, 4:30 PM