arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2111.01577cs.SEcs.ITcs.PLmath.IT
收藏

名称是否呼应语义?对 C++ 命名强制转换中所用标识符的大规模研究

Do Names Echo Semantics? A Large-Scale Study of Identifiers Used in C++'s Named Casts

Constantin Cezar Petrescu, Sam Smith, Rafail Giavrimis, Santanu Kumar Dash

AI总结:

本文提出基于条件熵的信息论方法,用于识别 C++ 显式类型转换中的不良实现,并在 Chromium 项目的大规模数据上验证了其有效性。

摘要:

开发者会放宽对某一类型的限制,以便与其他类型一起复用方法。虽然类型转换十分普遍,但在 C++ 这样的弱类型语言中,类型转换也极为宽松。如果源表达式被转换为新类型并赋值给新类型的目标变量,而操作不够谨慎,就可能导致软件缺陷。本文提出一种基于信息论的方法,用于识别显式转换操作中的不良实现。我们的方法使用条件熵来衡量源表达式与目标变量之间的一致性。我们从 Chromium 项目的 34 个组件中收集类型转换,这些组件合计约 2700 万行代码,并对该数据集进行随机均匀采样,构建了一个包含 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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑