This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] RetainCountChecker: recognize that OSObject can be created directly using an operator "new"
ClosedPublic

Authored by george.karpenkov on Nov 29 2018, 1:27 PM.

Diff Detail

Repository
rC Clang

Event Timeline

NoQ accepted this revision.Nov 29 2018, 3:24 PM
NoQ added inline comments.
clang/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
483–497 ↗(On Diff #175949)

It's actually just Call.getDecl() and you can turn this into a fall-through.

clang/test/Analysis/osobject-retain-release.cpp
27 ↗(On Diff #175949)

I think we should use size_t as much as possible, because this may otherwise have weird consequences on platforms on which size_t is not defined as unsigned long. Not sure if this checker is ran on such platforms. But the test doesn't have the triple specified, so it runs under the host triple, which may be arbitrary and cause problems on buildbots.

I.e.,

typedef __typeof(sizeof(int)) size_t;
// use size_t
This revision is now accepted and ready to land.Nov 29 2018, 3:24 PM
NoQ added inline comments.Nov 29 2018, 3:26 PM
clang/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
297 ↗(On Diff #175949)

This function is probably also entered for global operator new that isn't a method on any class. Does the function behave sanely in this case?

This revision was automatically updated to reflect the committed changes.
george.karpenkov marked an inline comment as done.Nov 30 2018, 12:38 PM
george.karpenkov added inline comments.
clang/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
483–497 ↗(On Diff #175949)

Call.getDecl() returns a Decl (gotta love Obj-C methods!).

I guess we can group all those cases, and cast the returned decl to FunctionDecl instead of casting the call.