This is an archive of the discontinued LLVM Phabricator instance.

[analyzer][NFC] Add tests for D132236
ClosedPublic

Authored by tomasz-kaminski-sonarsource on Sep 30 2022, 1:58 AM.

Details

Summary

D132236 would have introduced regressions in the symbol lifetime
handling. However, the testsuite did not catch this, so here we have
some tests, which would have break if D132236 had landed.

This patch addresses the comment https://reviews.llvm.org/D132236#3753238

Co-authored-by: Balazs Benics <balazs.benics@sonarsource.com>

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptSep 30 2022, 1:58 AM
tomasz-kaminski-sonarsource requested review of this revision.Sep 30 2022, 1:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 30 2022, 1:58 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Thank you! Increasing coverage in tests is always great.

clang/test/Analysis/NewDeleteLeaks.cpp
196

Could you please add some explanation for the test case? Thinking of the related patch, something like this could be a good explanation:

Check that memory leak is reported against a symbol if the last place it's mentioned is a base region of a lazy compound value, as the program cannot possibly free that memory.

And below, we should mention that p is that symbol and p->data is the lazy compound value.

clang/test/Analysis/symbol-reaper-lambda.cpp
9

Maybe it is just me, but this test case is a bit hard to follow. I guess it is a result of creduce. But still, could you please elaborate the following:

  1. What is the lazy compound value? (My weak guess is param)
  2. What is the base region?
  3. Which symbol is being reaped and where?
15

Did D132236 produce an FP warning for this?

Added requested comment for the example.
Included additional false-positive test.

tomasz-kaminski-sonarsource marked 2 inline comments as done.Oct 3 2022, 5:32 AM
tomasz-kaminski-sonarsource added inline comments.
clang/test/Analysis/symbol-reaper-lambda.cpp
15

Yes, it created false-positive for ref_capture load producing initialized value.

martong accepted this revision.Oct 3 2022, 5:42 AM

Thanks for the update! LGTM.

clang/test/Analysis/trivial-copy-struct.cpp
57 ↗(On Diff #464657)
This revision is now accepted and ready to land.Oct 3 2022, 5:42 AM
This revision was automatically updated to reflect the committed changes.
tomasz-kaminski-sonarsource marked an inline comment as done.