Skip to content
Open access

Automated Type-IV Clone Generation via LLMs and Deterministic Validation

Oct 2026 · Proceedings of the ACM on Software Engineering · Vol 3, pp. 1424 - 1446 · 1 citation · 56 references

Abstract

Detecting Type-IV code clones, functionally equivalent fragments with different syntax, remains a major challenge for quality assurance. Existing datasets are limited in supporting semantic clone detection due to class imbalance, lack of verified functional equivalence, and data redundancy. We present an automated approach for generating Type-IV clones by leveraging large language models (LLMs) with deterministic testing and filtering. The approach normalizes input code, produces diverse clone candidates through customizable prompts, and ensures semantic equivalence via automated testing and syntactic diversity through CodeBLEU-based filtering. Representative unique clones are then selected by clustering. We evaluate the extent to which LLMs generate diverse Python Type-IV clones, how prompt and generation factors affect quality and efficiency, the retention of only Type-IV clones at the final dataset, and the usefulness of the resulting dataset for fine-tuning embedding models. Results show that the generated clones improve Type-IV clone detection across different programming languages.

Read PDF

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.