[PATCH] D27773: [analyzer] Add checker modeling gtest APIs.
Devin Coughlin via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 14 13:55:54 PST 2016
dcoughlin created this revision.
dcoughlin added reviewers: zaks.anna, NoQ.
dcoughlin added subscribers: cfe-commits, alexfh, sbenza.
Herald added a subscriber: mgorny.
gtest is a widely-used unit-testing API provides macros for unit test
ASSERT_TRUE(p != nullptr);
that expand into an if statement that constructs an object representing
the result of the assertion and returns when the assertion is false:
if (AssertionResult gtest_ar_ = AssertionResult(p == nullptr))
Unfortunately, the analyzer does not model the effect of the constructor
precisely because (1) the copy constructor implementation is missing from the
the header (so it can't be inlined) and (2) the boolean-argument constructor
is constructed into a temporary (so the analyzer decides not to inline it since
it doesn't reliably call temporary destructors right now).
This results in false positives because the analyzer does not realize that the
the assertion must hold along the non-return path.
This patch addresses the false positives by explicitly modeling the effects
of the two un-inlined constructors on the AssertionResult state.
I've added a new package, "apiModeling", for these kinds of checkers that
model APIs but don't emit any diagnostics. I envision all the checkers in
this package always being on by default.
This addresses the false positives reported in PR30936.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 18824 bytes
Desc: not available
More information about the cfe-commits