Do names echo semantics? A large-scale study of identifiers used in C++'s named casts

Do names echo semantics? A large-scale study of identifiers used in C++'s named casts
复制标题

名称是否符合语义?

DOI:
10.1016/j.jss.2023.111693
复制
发表时间:
2023
影响因子:
3.5
通讯作者:
Petrescu C
Petrescu C
中科院分区:
计算机科学2区
文献类型:
--
作者:
Petrescu C

文献摘要

相似文献

开发人员放宽了对类型的限制,以便与其他类型一起重用方法。虽然类型转换很普遍,但在弱类型语言(如C++)中,它们也是非常宽松的。将源表达式转换为新类型并将其分配给新类型的目标变量,如果不小心执行,可能会导致软件错误。在本文中,我们提出了一个信息理论的方法来识别显式转换操作的执行差。我们的方法使用条件熵测量源表达式和目标变量之间的雅阁。我们从Chromium项目的34个组件中收集数据,这些组件总共占27兆字节,并对该数据集进行随机均匀采样,以创建一个包含271个数据的手动标记数据集。对这271个模型的信息论审查达到了81%的峰值精度和90%的召回率。我们还介绍了对显式转换的深入调查的结果,其中两个在Chromium项目的最新版本中得到了修复。
Developers relax restrictions on a type to reuse methods with other types. While type casts are prevalent, in weakly typed languages such as C++, they are also extremely permissive. Assignments where a source expression is cast into a new type and assigned to a target variable of the new type, can lead to software bugs if performed without care. In this paper, we propose an information-theoretic approach to identify poor implementations of explicit cast operations. Our approach measures accord between the source expression and the target variable using conditional entropy. We collect casts from 34 components of the Chromium project, which collectively account for 27MLOC and random-uniformly sample this dataset to create a manually labelled dataset of 271 casts. Information-theoretic vetting of these 271 casts achieves a peak precision of 81% and a recall of 90%. We additionally present the findings of an in-depth investigation of notable explicit casts, two of which were fixed in recent releases of the Chromium project.