This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Associate diagnostics created in checkEndFunction with a return statement, if possible
ClosedPublic

Authored by george.karpenkov on Sep 20 2018, 3:14 PM.

Diff Detail

Repository
rC Clang

Event Timeline

NoQ added inline comments.Sep 20 2018, 3:25 PM
clang/include/clang/Analysis/ProgramPoint.h
343–345 ↗(On Diff #166370)

I suspect we can always retrieve it as LC->getCFG()->getExit(), no need to store it separately.

clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
832–834 ↗(On Diff #166370)

This looks correct, but my completely irrational intuition suggests that createBegin() might be more appropriate. I.e., we're not computing something at the ; that follows the return-statement, but instead we are already below the return statement.

clang/include/clang/Analysis/ProgramPoint.h
343–345 ↗(On Diff #166370)

I think it's better to be consistent with the surrounding code here,
to make it obvious it behaves in the same way as BlockEntrancePoint

clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
832–834 ↗(On Diff #166370)

Does it matter though? What is the difference?

NoQ added inline comments.Sep 20 2018, 3:41 PM
clang/include/clang/Analysis/ProgramPoint.h
343–345 ↗(On Diff #166370)

I don't think it this program point has anything in common with BlockEntrancePoint, apart from the historical misuse of the latter.

clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
832–834 ↗(On Diff #166370)

It'll affect the column on which the report would be thrown, assuming code is written normally and the return value is short enough (otherwise it may also affect line).

george.karpenkov marked 2 inline comments as done.
NoQ accepted this revision.Sep 21 2018, 1:32 PM

Yay!

This revision is now accepted and ready to land.Sep 21 2018, 1:32 PM
This revision was automatically updated to reflect the committed changes.
This revision was automatically updated to reflect the committed changes.