This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] MallocChecker refactoring of calls checkers
Needs ReviewPublic

Authored by devnexen on Apr 9 2018, 2:36 PM.

Details

Summary
  • Splitting some by family to reduce the list of function identifiers.

Diff Detail

Repository
rC Clang

Event Timeline

devnexen created this revision.Apr 9 2018, 2:36 PM
NoQ added a subscriber: xazax.hun.

@xazax.hun: do you think the approach you took in the Valist checker is applicable here? Did you like how it ended up working? Cause i'd love to see CallDescription and initializer lists used for readability here. And i'd love to see branches replaced with map lookups. And i'm not sure if anybody has written code that has all the stuff that i'd love to see.

In D45458#1062342, @NoQ wrote:

@xazax.hun: do you think the approach you took in the Valist checker is applicable here? Did you like how it ended up working? Cause i'd love to see CallDescription and initializer lists used for readability here. And i'd love to see branches replaced with map lookups. And i'm not sure if anybody has written code that has all the stuff that i'd love to see.

Overall the CallDescription interface works really well if you do not need anything more advanced, e.g. supporting overloads. I can imagine that its current implementation is slightly less efficient since the lazy initialization logic of the identifiers are repeated for every identifier but that also makes it less bug-prone (do not have the implicit assumption that a set of identifiers should always exist together).

It would be great to extend the interface in the future, but one of the reasons I was reluctant to do so yet is performance. E.g.: having a simple check that a checker is interested only in global C functions is better than having this check repeated in every call description object in an array, or making it possible to do a StringSwitch like optimization with multiple statically known CallDescription objects would also be awesome.

But I think most of the time these tests would not be used on the hot paths anyways, so as long its current expressive power is sufficient, I prefer code that is utilizing this tool. It tends to make the code slightly shorter.

Szelethus retitled this revision from MallocChecker refactoring of calls checkers to [analyzer] MallocChecker refactoring of calls checkers.Dec 1 2018, 4:49 AM