Re: Identifying Dead Code
Re: Identifying Dead Code
- Subject: Re: Identifying Dead Code
- From: Dmitry Markman <email@hidden>
- Date: Fri, 22 Jun 2012 23:06:14 -0400
Actually I found instructions from
http://stackoverflow.com/questions/5852002/xcode-code-coverage
only you don't have to set other link flags to -lgcov
1. Enable “Generate Test Coverage Files”
2. Enable “Instrument Program Flow”
3. build and run
4. in your build directory you should see files like
main.gcda
main.gcno
run gcov
and you'll see many *.gcov files
hope it will help
dm
On Jun 22, 2012, at 10:46 PM, Dmitry Markman wrote:
> did you try gcov?
>
> I'm not sure clang has similar tool
>
> see
>
> http://permalink.gmane.org/gmane.comp.compilers.clang.devel/21158
>
> here
>
> http://stackoverflow.com/questions/5852002/xcode-code-coverage
>
> you can see that LLVM has gcov support, but I'm not sure if Apple clang has it
>
> dm
>
>
>
>
> On Jun 20, 2012, at 7:10 PM, Jens Alfke wrote:
>
>>
>> On Jun 20, 2012, at 3:20 PM, Gordon Apple wrote:
>>
>>> Well, if it’s commented out, it’s obviously not getting called. Yes, I mean live code, methods, etc, that nobody calls. Sometimes I might leave something in, just in case I want it later, but I’m mostly talking about code that has been replaced or rendered unneeded. Many times, I comment something out just to see who, if anybody, complains. That takes a lot of time if there are a lot of code to be checked. It would be a lot easier if xcode could identify unreachable code, and let me decide whether or not to zap it.
>>
>> Well, there's an optional warning for unused static functions, that you can enable.
>>
>> Beyond that, I don't know of any automated checks. The linker will dead-strip unreachable functions, but I don't know if there's a way to have it report what it stripped.
>>
>> Also, what language is this? It's fairly easy to tell if C functions are unreachable, but difficult with C++ virtual methods, and impossible with Objective-C methods (since any method is callable even if its selector never appears in the source code; after all, that kind of thing happens all the time when nibs are loaded.)
>>
>> —Jens
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Xcode-users mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
> Dmitry Markman
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
Dmitry Markman
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden