Skip to content

C++: Fix cpp/new-free-mismatch false positives #3206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Apr 8, 2020
Merged

Conversation

geoffw0
Copy link
Contributor

@geoffw0 geoffw0 commented Apr 6, 2020

There were four new false positives for cpp/new-free-mismatch in g/abseil/abseil-cpp. The issue was that calls to allocator new were being misrecognized as malloc-style allocations because they were function calls.

I've added test cases and tidied some things up as I went along, including deprecating another part of the legacy wrapper alloc.qll (something I've been meaning to get around to).

I'm thinking about the next step being wrapping the concept of an allocation kind ("malloc", "new", "new[]") into the models themselves so that we can simplify this and similar code. Perhaps we should also create additional kinds for some of the more exotic allocators, so that we can detect more kinds of mismatches.

@geoffw0 geoffw0 added the C++ label Apr 6, 2020
@geoffw0 geoffw0 requested a review from a team as a code owner April 6, 2020 14:12
@rdmarsh2
Copy link
Contributor

rdmarsh2 commented Apr 6, 2020

The QLDoc check is failing because this is exposing the model/implementation qlls. I think importing those privately would be OK.
LGTM otherwise.

I think moving the matching into the models is a good idea, but I might have the model make the decision about specific functions or expressions rather than using strings. In any case, we should probably talk about it in an issue rather than a PR.

@geoffw0
Copy link
Contributor Author

geoffw0 commented Apr 7, 2020

I've added QLDoc to the top of those files. It's fairly minimal, but points users to the files in interfaces that are a better starting point.

@jbj jbj added this to the 1.24 milestone Apr 7, 2020
@jbj
Copy link
Contributor

jbj commented Apr 7, 2020

qlformat failed :-/

rdmarsh2
rdmarsh2 previously approved these changes Apr 7, 2020
Copy link
Contributor

@rdmarsh2 rdmarsh2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once the qlformat is fixed.

@geoffw0
Copy link
Contributor Author

geoffw0 commented Apr 7, 2020

Sorry about that. Should pass this time...

Copy link
Contributor

@jbj jbj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robert has reviewed, and the tests are passing.

@jbj jbj merged commit 42e9d14 into github:master Apr 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants