This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Insert notes in RetainCountChecker where our dynamic cast modeling assumes 'null' output
ClosedPublic

Authored by george.karpenkov on Jan 18 2019, 5:58 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

NoQ accepted this revision.Jan 18 2019, 6:11 PM
NoQ added inline comments.
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
266–267 ↗(On Diff #182656)

I think you can put tags themselves here (as non-static members) and compare them by pointers later.

clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
514 ↗(On Diff #182656)

I think that there should be a note when the cast succeeds.

Another thing to think about: should we add these pieces on *all* casts? Wouldn't it lead to displaying too much inlined diagnostics? Should we somehow mark these as prunable? Should we display them only when interesting objects are casted?

This revision is now accepted and ready to land.Jan 18 2019, 6:11 PM
george.karpenkov marked 2 inline comments as done.Jan 22 2019, 11:25 AM
george.karpenkov added inline comments.
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
266–267 ↗(On Diff #182656)

That would be better - but then I need access to the checker in the visitor.
I guess I could just cast it =/

clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
514 ↗(On Diff #182656)

I think that there should be a note when the cast succeeds.

Not sure, usually readers assume that the cast succeeds when reading the code.

Another thing to think about: should we add these pieces on *all* casts?

I haven't seen too much diagnostics from this in practice (by manually looking at reports).

Should we display them only when interesting objects are casted?

Again not sure =/ Even if the object is not interesting failed casts can lead us to enter unexpected branches.

george.karpenkov marked an inline comment as done.
This revision was automatically updated to reflect the committed changes.