Preview

Proceedings of the Institute for System Programming of the RAS (Proceedings of ISP RAS)

Advanced search

Lazy source code analysis for C/C++ languages

https://doi.org/10.15514/ISPRAS-2012-23-8

Abstract

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.

About the Authors

V. O. Savitsky
ISP RAS, Moscow
Russian Federation


D. V. Sidorov
ISP RAS, Moscow
Russian Federation


References

1. http://www.easterbrook.ca/steve/?p=694

2. A. Avetisyan, A. Belevantsev, A. Borodin, V. Nesov Ispol'zovanie staticheskogo analiza dlya poiska uyazvimostej i kriticheskikh oshibok v iskhodnom kode programm[Using static analysis for finding security vulnerabilities and critical errors in source code] Trudy ISP RAN [The Proceedings of ISP RAS], 2012, vol 21, pp. 23-38 (in Russian)

3. V. O. Savitsky, D. V. Sidorov, Inkremental'nyj analiz iskhodnogo koda na yazykakh C/C++[Incremental source code analysis for C/C++ languages] Trudy ISP RAN [The Proceedings of ISP RAS], 2012, vol 22, pp. 119-129 (in Russian)

4. http://msdn.microsoft.com/en-us/library/x5w1yety%28v=vs.71%29.aspx

5. Aho, Sethi, Ullman, Compilers: Principles, Techniques, and Tools, Addison-Wesley, 1986


Review

For citations:


Savitsky V.O., Sidorov D.V. Lazy source code analysis for C/C++ languages. Proceedings of the Institute for System Programming of the RAS (Proceedings of ISP RAS). 2012;23. (In Russ.) https://doi.org/10.15514/ISPRAS-2012-23-8



Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 License.


ISSN 2079-8156 (Print)
ISSN 2220-6426 (Online)