This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] PthreadLock: Fix return values of XNU lock functions.
ClosedPublic

Authored by NoQ on Sep 13 2017, 6:38 AM.

Details

Summary

lck_mtx_lock() returns void. The analyzer failed to model its effect because he was surprised that the return value is Unknown. Prepare for the aforementioned surprise and fix the tests accordingly.

Diff Detail

Event Timeline

NoQ created this revision.Sep 13 2017, 6:38 AM
zaks.anna added inline comments.Sep 13 2017, 8:51 AM
lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
271 ↗(On Diff #115029)

This comment is repeated several times...

test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h
29 ↗(On Diff #115029)

Should there be a test added that uses the function?

NoQ added inline comments.Sep 17 2017, 12:49 PM
lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
271 ↗(On Diff #115029)

Because it is relevant in both places. Should i rephrase with "also"/"as well"/"here too"?

test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h
29 ↗(On Diff #115029)

The tests are already there for all three functions. I just fixed their prototype to match the real-world prototype, and then adjusted the code accordingly, so that the existing tests kept passing.

a.sidorin edited edge metadata.Nov 13 2017, 6:39 AM

Hi Artem,

Sorry for long delay for reviews. Unfortunately, hospital is a bad place to do a code review and broken hand is a bad review assistant. This patch looks good to me, I have just a minor comment nit.

lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
282 ↗(On Diff #115029)

TODO?

NoQ added a comment.Nov 28 2017, 9:11 AM

Hey wb! Get well :)

lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
282 ↗(On Diff #115029)

That'd make a terrible project of choice for people grepping for TODOs and FIXMEs, so I guess rather not.

a.sidorin accepted this revision.Nov 28 2017, 9:20 AM

Looks good to me.

lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
271 ↗(On Diff #115029)

Small rephrasing will be good because it will clearly state that it is not a copy-paste error :)

This revision is now accepted and ready to land.Nov 28 2017, 9:20 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJan 24 2020, 7:44 AM