paperbot · PL 论文追踪

全部论文 待读 收藏

P2 F <scp>a</scp> C <scp>o</scp> Y

FaCoY:一种静态查找语义相似代码片段的代码到代码搜索方法
ICSE Proceedings of the 40th International Conference on Software Engineering2018匹配度 2/10 · 该论文是静态代码搜索/语义克隆检测,属于传统程序分析工具,不涉及 LLM/Agent、浮点程序分析或贝叶斯程序分析,与用户核心研究交叉方向(PL 与 AI/LLM 结合)几乎无关。引用 87 inbox
Kisub Kim, Dongsun Kim, Tegawendé F. Bissyandé, Eunjong Choi, Li Li, Jacques Klein, Yves Le Traon
crossref: 2026-09-12

AI 速览

一句话:提出 FaCoY,通过查询改写静态搜索与输入代码语义相似的代码片段。

代码搜索是软件开发中的常见活动,但现有方法多面向自然语言查询,缺乏对代码到代码搜索的支持。论文提出 FaCoY,一种静态查找与用户输入代码在语义上可能相似的代码片段的方法。FaCoY 采用查询改写策略:不直接将代码查询 token 与搜索空间中的代码匹配,而是先识别可能同样参与实现输入代码功能行为的其他 token。实验表明,FaCoY 比在线代码到代码搜索引擎更有效;在 BigCloneBench 上比现有方法检测出更多语义代码克隆(Type-4);尽管是静态方法,仍能发现运行时执行行为确实相似的代码片段;并可用于代码/补丁推荐。

问题
现有代码搜索多面向自然语言查询,而代码到代码场景(如代码移植、代码多样性、补丁推荐)需要从输入代码出发查找语义相似片段。
方法
FaCoY 采用静态查询改写策略,先为输入代码识别可能在功能实现中相关的其他 token,再在搜索空间中匹配,以发现语义而非仅词法相似的代码。
评估
在多个实验中与在线代码到代码搜索引擎比较,在 BigCloneBench 上评估 Type-4 语义克隆检测,并验证运行时行为相似性及代码/补丁推荐用途。
原文摘要(Abstract)

Code search is an unavoidable activity in software development. Various approaches and techniques have been explored in the literature to support code search tasks. Most of these approaches focus on serving user queries provided as natural language free-form input. However, there exists a wide range of use-case scenarios where a code-to-code approach would be most beneficial. For example, research directions in code transplantation, code diversity, patch recommendation can leverage a code-to-code search engine to find essential ingredients for their techniques. In this paper, we propose FaCoY, a novel approach for statically finding code fragments which may be semantically similar to user input code. FaCoY implements a query alternation strategy: instead of directly matching code query tokens with code in the search space, FaCoY first attempts to identify other tokens which may also be relevant in implementing the functional behavior of the input code. With various experiments, we show that (1) FaCoY is more effective than online code-to-code search engines; (2) FaCoY can detect more semantic code clones (i.e., Type-4) in BigCloneBench than the state-of-the-art; (3) FaCoY, while static, can detect code fragments which are indeed similar with respect to runtime execution behavior; and (4) FaCoY can be useful in code/patch recommendation.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@inproceedings{paperbot4417,
  title = {F
            <scp>a</scp>
            C
            <scp>o</scp>
            Y},
  author = {Kisub Kim and Dongsun Kim and Tegawendé F. Bissyandé and Eunjong Choi and Li Li and Jacques Klein and Yves Le Traon},
  booktitle = {ICSE},
  year = {2018},
  doi = {10.1145/3180155.3180187}
}