Page MenuHomePhabricator

[analyzer] NFC: Move stack hints to a side map.
ClosedPublic

Authored by NoQ on Mon, Sep 9, 4:38 PM.

Details

Summary

Stack hints are attached to PathDiagnosticEventPieces in order to improve path notes at the call site for the call in which the event has occured. For example, they are currently used only by MallocChecker in order to produce the fancy "Returning allocated memory"/"Returning; memory was released" note. By the way, in fact nobody else currently uses this functionality - only MallocChecker.

I want to make the PathDiagnostic interface completely ignorant of Static Analyzer specific concepts such as ExplodedNode or SymbolRef, so i moved this interface to BugReporter. Stack hints are now owned by the PathSensitiveBugReport object against which the visitor emits event pieces for which it needs stack hints.

I'm open to discuss a better design here. Eg., i thought about making it part of the visitor interface instead, but i don't immediately see how to do this without breaking the logic of "only add the note at the call site in which the event has happened, not every time allocated memory is returned from anywhere".

Diff Detail

Event Timeline

NoQ created this revision.Mon, Sep 9, 4:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptMon, Sep 9, 4:38 PM
Szelethus accepted this revision.Wed, Sep 11, 4:46 AM

I'm open to discuss a better design here. Eg., i thought about making it part of the visitor interface instead, but i don't immediately see how to do this without breaking the logic of "only add the note at the call site in which the event has happened, not every time allocated memory is returned from anywhere".

When I stumbled upon this stack hint thingie during the refactoring of BugReporter.cpp, I found it very clunky, and while I still do, I'm none the wiser about how to do it any better.

Side note, now that you had to work with the freshly rewritten file, do you have any feedback on it?

clang/lib/StaticAnalyzer/Core/BugReporter.cpp
333–337

How about a simple twine?

clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
34

Nice, how did you catch this? Some compiler warning?

This revision is now accepted and ready to land.Wed, Sep 11, 4:46 AM
gribozavr accepted this revision.Wed, Sep 11, 5:11 AM
NoQ marked an inline comment as done.Wed, Sep 11, 10:54 AM
NoQ added inline comments.
clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
34

No, it's just that removing these includes is the whole point of the patch. In order to be able to move this file out of static analyzer, it should not include headers from static analyzer. This patch removes one such include.

NoQ marked 2 inline comments as done.Wed, Sep 11, 1:52 PM

Side note, now that you had to work with the freshly rewritten file, do you have any feedback on it?

Dunno, i'm a very functional / pure / stateless person. "I debugged, I edited, I forgot". "I suffer from short-term memory loss".

But given that it was fairly easy for me to focus on the task at hand and this whole thing was definitely not traumatizing, i suspect that the file ended up in a fairly good shape and i can't complain.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptWed, Sep 11, 1:54 PM