Lazy source code analysis for C/C++ languages

The article describes a way to implement syntax analysis for C/C++ languages which allows to reduce significantly the required resources. The method is based on the fact that each source file includes lots of header files from which only a portion of definitions is used. The analysis of definitions...

Full description

Bibliographic Details
Main Authors: V. O. Savitsky, D. V. Sidorov
Format: Article
Language:English
Published: Ivannikov Institute for System Programming of the Russian Academy of Sciences 2018-10-01
Series:Труды Института системного программирования РАН
Subjects:
Online Access:https://ispranproceedings.elpub.ru/jour/article/view/977
Description
Summary:The article describes a way to implement syntax analysis for C/C++ languages which allows to reduce significantly the required resources. The method is based on the fact that each source file includes lots of header files from which only a portion of definitions is used. The analysis of definitions in headers can be postponed to the moment of actual access to them, thus avoiding the analysis of definitions that are never used. Such definitions as templates, classes, functions could be skipped during code parsing until access of such definitions will be found in source code. For these purposes parser of C/C++ code modified to support postponed parsing of skipped parts along with revision system like caching of semantic information for parsed code. As the result of implementation of such parser performance growth of source code parsing up to 36% observed on several open source projects. The distinctive feature of this method is that only a small amount of changes is required to add the "lazy" behaviour to an existing parser.  This method of source code parser performance improvement is implemented in the Klocwork Insight static analyzer.
ISSN:2079-8156
2220-6426