Page MenuHomePhabricator

[analyzer] StdLibraryFunctionsChecker: Add overload for adding the same summary for different names
AbandonedPublic

Authored by martong on May 5 2020, 8:52 AM.

Details

Summary

Adding a convenience function for makeing it easier to add the same summary for functions with different names.
E.g. we are going to use the same summary for

char * strchr(const char *cs, int c);
char * strrchr(const char * str, int character);

Diff Detail

Event Timeline

martong created this revision.May 5 2020, 8:52 AM
balazske added inline comments.May 6 2020, 12:08 AM
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
672

Theoretically it is possible to have a multiple names-multiple summaries case (multiple function names that have the same overloads)?

I'd prefer to have this functionality committed together its first actual use with tests.

I also agree with @balazske, we should diagnose the cases when we have multiple summaries for the same function.

martong marked 2 inline comments as done.Jun 23 2020, 1:54 AM

I'd prefer to have this functionality committed together its first actual use with tests.

Okay, at the current state we add a summary individually for each name, that makes it easier to modify a summary for each function without effecting other functions.

I also agree with @balazske, we should diagnose the cases when we have multiple summaries for the same function.

We already handle these cases with an assertion:

auto Res = Map.insert({FD->getCanonicalDecl(), S});
assert(Res.second && "Function already has a summary set!");
(void)Res;
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
672

I think yes, that would be possible.

martong abandoned this revision.Jun 23 2020, 1:56 AM
martong marked an inline comment as done.

At the current state we add a summary individually for each name, that makes it easier to modify a summary for each function without effecting other functions. I'll add this functionality in the future when a real use cases comes up, if that really comes up.