|
Copy-paste semantic errors detection
Sevak Sargsyan Institute for System Programming of the Russian Academy of Sciences
Abstract:
The paper describes a method for semantic errors detection arising during incorrect code copy-paste made by the developer. The method consists of two basic parts. The first part detects code clones based on lexical analysis of the program. A sequence of tokens is constructed based on the LLVM lexer and then all pairs of maximal, non-intersected matched token sequences are detected. The pairs of identical subsequences are then partially parsed to retain the constructs allowed by the programming language and to remove the incomplete sequences. When the remaining subsequences are big enough, the second stage is applied for them. A Program Dependence Graph (PDG) is constructed for the corresponding function code, and then identical subsequences’ subgraphs are considered. If two subgraphs have shared vertices, then outgoing edges of these vertices are analyzed. This allows detecting semantic errors with high accuracy. The described method is implemented for the LLVM/Clang compiler. Due to this semantic mistakes are detected during program compile time, so there is no need for separate lexical and semantic program analysis. A number of widely used open source libraries and software systems were analyzed. The paper contains the list of detected semantic errors for Linux kernel 2.6 and Android 4.3. For these systems, the true positive rate achieved by our approach is above 65%.
Keywords:
lexical analysis, semantic analysis, code clones, PDG, LLVM.
Citation:
Sevak Sargsyan, “Copy-paste semantic errors detection”, Proceedings of ISP RAS, 27:2 (2015), 93–104
Linking options:
https://www.mathnet.ru/eng/tisp124 https://www.mathnet.ru/eng/tisp/v27/i2/p93
|
Statistics & downloads: |
Abstract page: | 205 | Full-text PDF : | 78 | References: | 40 |
|