This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] ExprEngine: don't launch PreStmt<CastExpr> twice
ClosedPublic

Authored by a.sidorin on Aug 23 2016, 8:20 AM.

Details

Summary

CheckerManager::runCheckersForPreStmt() is called twice for CastExpr: first, in ExprEngine::Visit() and then in ExprEngine::VisitCast(). This patch removes the first check as redundant.

This patch lacks a test case. If you have any idea for a test case, please, share it :)

Diff Detail

Repository
rL LLVM

Event Timeline

a.sidorin updated this revision to Diff 68995.Aug 23 2016, 8:20 AM
a.sidorin retitled this revision from to [analyzer] ExprEngine: don't launch PreStmt<CastExpr> twice.
a.sidorin updated this object.
a.sidorin added reviewers: zaks.anna, dcoughlin, NoQ.
zaks.anna accepted this revision.Aug 23 2016, 9:28 PM
zaks.anna edited edge metadata.

LGTM. Thanks!

This revision is now accepted and ready to land.Aug 23 2016, 9:28 PM
NoQ edited edge metadata.Aug 24 2016, 3:39 AM

Maybe we could extend CheckerDocumentationChecker to print stuff whenever any callback is called (since it's anyway subscribed on all callbacks in existence; or make a separate debug checker), and make tests that ensure that the callback order is what we expect.

It might lead to a few more interesting discoveries.

I like the idea of a separate debug checker like AnalysisCallbackOrder. Will try to implement.

a.sidorin updated this revision to Diff 69366.Aug 26 2016, 7:06 AM
a.sidorin edited edge metadata.

Add a test checker and a test to ensure that patch works as expected.

NoQ added inline comments.Aug 26 2016, 9:16 AM
lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
25 ↗(On Diff #69366)

Not sure we need those.

32 ↗(On Diff #69366)

Hmm, you aren't looking for the easy path, are you :) That might lead to a huge visitor-like macro magic if you want to turn particular statement kind groups on and off.

I think it's not scary to enable all callbacks at once. Maybe print statement kind in each callback. The only outcome of this would be ... more tests! Which doesn't sound that bad.

a.sidorin added inline comments.Aug 29 2016, 1:45 AM
lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
32 ↗(On Diff #69366)

Hi! I was not going for "-enable/-disable" style. The target of this is to keep regression tests as easy as possible. Otherwise, we may need to change every test after adding a callback. This may also make tests to test not what they need to test and I don't like it. I may add '*'-mode, but if somebody needs to see all callbacks fired, ViewExplodedGraph is much better tool to use.

a.sidorin updated this revision to Diff 69543.Aug 29 2016, 2:02 AM

Remove namespace usage; implement a '*'-mode to print all callbacks.

NoQ accepted this revision.Aug 29 2016, 2:50 AM
NoQ edited edge metadata.

Cool!

This revision was automatically updated to reflect the committed changes.