代码拉取完成,页面将自动刷新
/**
* @name Function is never called
* @description Unused functions may increase object size, decrease readability, and create the possibility of misuse.
* @kind problem
* @id cpp/dead-code-function
* @problem.severity warning
* @tags maintainability
* external/cwe/cwe-561
*/
import cpp
predicate limitedScope(Function f) {
f.isStatic() and not f instanceof MemberFunction
or
f.(MemberFunction).isPrivate()
}
predicate uncalled(Function f) {
limitedScope(f) and
not exists(Function g | g = f or g = f.(VirtualFunction).getAnOverriddenFunction+() |
exists(g.getACallToThisFunction()) or
exists(FunctionAccess fa | fa.getTarget() = g)
)
}
from Function f
where
uncalled(f) and
forall(Function instance | f.(TemplateFunction).getAnInstantiation() = instance |
uncalled(instance)
) and
// tweaks for good results:
exists(f.getBlock()) and
not (f instanceof Constructor or f instanceof Destructor or f.hasName("operator="))
select f, "Dead Code: this function is never called."
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。