This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Correctly propagate ConstructionContextLayer thru ParenExpr
ClosedPublic

Authored by tomasz-kaminski-sonarsource on May 20 2021, 2:49 AM.

Details

Summary

Previously, information about ConstructionContextLayer was not propagated thru causing the expression like:
Var c = (createVar());
To produce unrelated temporary for the createVar() result and conjure new symbol for value of c in C++17 mode.

Diff Detail

Event Timeline

tomasz-kaminski-sonarsource requested review of this revision.May 20 2021, 2:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 20 2021, 2:49 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Added // no warn comment to line that was raising warning before the fix.

This looks great!

clang/test/Analysis/NewDelete-checker-test.cpp
44–55

This mail adds some insight into the usage of c++-allocator-inlining:

https://lists.llvm.org/pipermail/cfe-dev/2020-February/064754.html

About the code in MallocChecker that handles this flag (NewDelete is a part of this as well):

Yes, we should remove the old code for c++-allocator-inlining=false. The worry we've had back then as that in the new mode we've disabled aggressive behavior of MallocChecker in which it reacted to some overloaded operator new invocations but i think this was the right thing to do and also nobody complained; also nothing prevents us from bringing back the old behavior in a much less confusing way.

As a response, D75432 removed all code that handed c++-allocator-inlinging=false. So these RUN lines can be removed I think.

57–60

This last RUN seems to be the same as the first.

clang/test/Analysis/NewDelete-checker-test.cpp
57–60

This checker enables NewDeleteLeaks, while first enables NewDelete. From what I have checked, this two seem to have different behavior.

Removed duplicated runs that were only differing by specifying c++-allocator-inlinging=true, which is the default value.

clang/test/Analysis/NewDelete-checker-test.cpp
44–55

I have removed new runs with the c++-allocator-inlinging=true, and checked other files that have duplicated runs, and removed them.

Looks good to me.

Szelethus added inline comments.May 20 2021, 5:26 AM
clang/test/Analysis/NewDelete-checker-test.cpp
57–60

Oh, silly me. you're right. :)

Adjusted Clang.Analysis::NewDelete-path-notes.cpp.plist for removed lines.

I do not have commit rights. If there are no additional changes needed, would it be possible to you to commit the changes on my behalf?

steakhal accepted this revision.May 21 2021, 9:35 AM

I do not have commit rights. If there are no additional changes needed, would it be possible to you to commit the changes on my behalf?

I wanted to wait for a couple of days to see if anyone else has something to say.
I'm gonna commit your change on your behalf on Monday if it's good for you.

This revision is now accepted and ready to land.May 21 2021, 9:35 AM