Reputation: 5890
I know that functions can be called dynamically, but is there a way to determine statically which functions (and methods of ObjC objects) are not being called?
Upvotes: 5
Views: 793
Reputation: 104698
add -Wunused-function
to your list of WARNING_CFLAGS
.
this also considers functions taken by address as referenced (ideal for normal usage). then compile your program with gcc and clang for optimal coverage.
note that this flag does not cover all cases (e.g. exported functions), and it focuses primarily on functions which have internal linkage. diffing using strip
and nm
can help isolate external symbols -- i don't know of a good tool for this exact process.
if you want to locate unused objc methods, you should reword your question.
Upvotes: 0
Reputation: 26478
objc_cover will help you spotting potentially unused Objective-C methods.
Upvotes: 2
Reputation: 9124
I'm not sure that this is a sensible thing for someone to have attempted to make such a static analysis tool - it would be very complicated, and you would probably find that it would only find trvial examples of functions that would not be called - e.g. functions you've created in your classes, and you have no calls to them. All the stuff that interacts with Cocoa ... well the problem is that they 'might' be called in different circumstances.
In any case, what you should really be interested in is runtime code coverage - as this would show you (with a decent suite of tests) what code is actually being used, which would be a smaller subset.
Upvotes: 2