Skip to content

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

Merged
jbj merged 11 commits into
github:masterfrom
geoffw0:newfreefix
Apr 8, 2020
Merged

C++: Fix cpp/new-free-mismatch false positives#3206
jbj merged 11 commits into
github:masterfrom
geoffw0:newfreefix

Conversation

@geoffw0

@geoffw0 geoffw0 commented Apr 6, 2020

Copy link
Copy Markdown
Contributor

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

rdmarsh2 commented Apr 6, 2020

Copy link
Copy Markdown
Contributor

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

geoffw0 commented Apr 7, 2020

Copy link
Copy Markdown
Contributor Author

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

jbj commented Apr 7, 2020

Copy link
Copy Markdown
Contributor

qlformat failed :-/

rdmarsh2
rdmarsh2 previously approved these changes Apr 7, 2020

@rdmarsh2 rdmarsh2 left a comment

Copy link
Copy Markdown
Contributor

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

geoffw0 commented Apr 7, 2020

Copy link
Copy Markdown
Contributor Author

Sorry about that. Should pass this time...

@jbj jbj left a comment

Copy link
Copy Markdown
Contributor

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