dead-code

Java constant expressions and code elimination

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 02:08:01
问题 As discussed here, javac and other Java compilers may provide code elimination capabilities for if -statements where the condition is a "Constant Expression". How is this affected if my code uses a constant expression that depends on other constant expressions defined in different packages? For example, let's say I have the following classes in the respective specified packages: package foo; public class Foo { public static final boolean CONDITION = false; } and package bar; import foo.Foo;

Identifying Unused Functions in C/C++ [duplicate]

旧街凉风 提交于 2019-12-08 00:44:53
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Finding “dead code” in a large C++ legacy application My project has a lots of C source files each with a lots of global functions. Many of these are no longer referenced by any caller at all. Is there a simple way to identify which of these functions are not referenced by anyone at all? The map file generated by VC seems to be useful. But I am not sure exactly how/when a function name is listed in the map file.

Xcode — finding dead methods in a project

久未见 提交于 2019-12-07 03:23:47
问题 I am curious if there are any tools that provide partial solutions for this. It is a tricky problem because of performSelector . . . but a tool ought to at least be able to come up with candidates, making the human's job easier. 回答1: Using static analysis, it is impossible to detect functions/methods that are defined but not used due to dynamic nature of Objective-C. The only reasonable solution is to run a coverage using GCov or similar tool. Even then, you will have to make your program do

Identifying Unused Functions in C/C++ [duplicate]

自闭症网瘾萝莉.ら 提交于 2019-12-06 05:20:22
This question already has answers here : Closed 7 years ago . Possible Duplicate: Finding “dead code” in a large C++ legacy application My project has a lots of C source files each with a lots of global functions. Many of these are no longer referenced by any caller at all. Is there a simple way to identify which of these functions are not referenced by anyone at all? The map file generated by VC seems to be useful. But I am not sure exactly how/when a function name is listed in the map file. Brady You can use CCCC (free, open source) which gives you lots of metrics about your program. Another

Xcode — finding dead methods in a project

北城余情 提交于 2019-12-05 06:51:37
I am curious if there are any tools that provide partial solutions for this. It is a tricky problem because of performSelector . . . but a tool ought to at least be able to come up with candidates, making the human's job easier. Using static analysis, it is impossible to detect functions/methods that are defined but not used due to dynamic nature of Objective-C. The only reasonable solution is to run a coverage using GCov or similar tool. Even then, you will have to make your program do everything possible in order to make sure that you do not strip out some feature that was just not used

Java Compiler: Stop complaining about dead code

自作多情 提交于 2019-12-05 03:19:35
For testing purposes, I often start typing some code in an already existing project. So, my code I want to test comes before all the other code, like this: public static void main(String[] args) { char a = '%'; System.out.println((int)a); // To know where '%' is located in the ASCII table. // But, of course, I don't want to start the whole project, so: return; // The real project starts here... } But the compiler complains about the return -statement, because of the following "dead code". (While in C++ the compiler obeys the programmer and simply compiles the return statement) To prevent the

Is it bad to enable Dead Code Stripping?

核能气质少年 提交于 2019-12-04 08:15:12
My iOS project uses dlsym to dynamically point to an optional C library. Optional as-in the project can run with our without it, it just adds features. For background info: Detect and use optional external C library at runtime in Objective-C The problem is, XCode cleans up libraries that are "not used". Using dlsym means there are no direct references to my 3rd party library and XCode removes it. I thought I found a solution, in "Other Linker Flags" I added -force_load "$(SRCROOT)/my_external.a" which worked great in the simulator. ( -all_load works fine too but seemed overkill to me). The

Automated Dead code detection in native C++ application on Windows?

╄→гoц情女王★ 提交于 2019-12-03 06:57:40
问题 Background I have an application written in native C++ over the course of several years that is around 60 KLOC. There are many many functions and classes that are dead (probably 10-15% like the similar Unix based question below asked). We recently began doing unit testing on all new code and applying it to modified code whenever possible. However, I would make a SWAG that we have less than 5% test coverage at the present moment. Assumptions/Constraints The method and/or tools must support:

Java: Dead code elimination

大憨熊 提交于 2019-12-01 15:18:39
问题 I'd like to know how Java would handle the following scenario: Suppose I have a class called Debug, which looks like this: public class Debug { private static final boolean isAssertEnabled = true; public static void assertTrue(boolean b, String errorMessage) { if (isAssertEnabled) { if (!b) { throw new RuntimeException(errorMessage); } } } } and suppose my code has a call that looks something like this: ... Debug.assertTrue((x + y != z) && (v - u > w), "Some error message"); .... I have a few

How to find dead code in a large react project?

非 Y 不嫁゛ 提交于 2019-11-30 14:40:01
In order to refactor a client-side project, i'm looking for a safe way to find (and delete) unused code. What tools do you use to find unused/dead code in large react projects? Our product has been in development for some years, and it is getting very hard to manually detect code that is no longer in use. We do however try to delete as much unused code as possible. Suggestions for general strategies/techniques (other than specific tools) are also appreciated. Thank you First of all, very good question, in large project coders usually try many lines of code test and at the end of result, hard