This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Bugfix for autorelease + main run loop leak checker
ClosedPublic

Authored by george.karpenkov on Jul 27 2018, 10:54 AM.

Diff Detail

Repository
rC Clang

Event Timeline

NoQ added inline comments.Jul 30 2018, 2:33 PM
clang/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp
126–127 ↗(On Diff #157708)

Can this logic be moved into the matcher, eg. hasAncestor(autoreleasePoolStmt(unless(equalsBoundNode(AutoreleasePoolBind))))? The good thing here, apart from moving more logic into matchers, would be that we won't be relying on the order in which ancestors are matched.

clang/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp
126–127 ↗(On Diff #157708)

I'm not sure the relation I need can be encoded with existing matchers =/
(though maybe a new one can be created).

The problem is that there's no way to "fix" the hasAncestor matcher at the closest ancestor of a given type (kind of hasParent), and if it does not find a match, it would move on to further ancestors.

NoQ added inline comments.Jul 30 2018, 2:58 PM
clang/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp
126–127 ↗(On Diff #157708)

Hmm, okay,

hasAncestor(autoreleasePoolStmt(
  hasAncestor(autoreleasePoolStmt(equalsBoundNode(AutoreleasePoolBind)))))

?

NoQ accepted this revision.Jul 30 2018, 3:00 PM

Though i guess it's O(n²) of a matcher already. I'm fine with both approaches.

This revision is now accepted and ready to land.Jul 30 2018, 3:00 PM
This revision was automatically updated to reflect the committed changes.