Finding unused (aka “dead”) code in Delphi

后端 未结 8 2172
忘掉有多难
忘掉有多难 2021-01-01 23:51

Are there any tools that can determine if a function/procedure/method/entire class is used?

I\'ve seen tools that can help a knowledgeable developer track down unus

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-02 00:29

    For units, use Pascal Analyzer. You might need to use it a multiple of times.

    For objects/classes that are registered in class factories (and the like), you will need to double check manually, as they will be fully compiled in. The reason for this is that the compiler doesn't know if you actually use them or not.

    For methods, you need to check for the blue dots. Not very practical, so there is another way (from what I have been told when I investigate the same topic). You need to do a full build with a detailed map file enabled. Once that is done, you need to compare the source to see if there is an entry in the map file. If not, then the code is not compiled in - possibly dead code (possibly because if it is component, then it might be that you don't use that functionality).

提交回复
热议问题