Preview

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

Advanced search

Incremental source code analysis for C/C++ languages

Abstract

The article describes a way of implementing static code analysis for C/C++ languages that allows to reduce dramatically the time of the second and following analysis iterations. Main idea behind algorithm based on fact that programs on C/C++ languages widely use common parts of code placed inside header files with declarations and such header files included inside of several compilation units of projects. The ratio of the number of tokens in the source file to the number of tokens in the included headers is small. It is possible to reduce time of analysis using cache of compilation results for rarely changed part of compilation unit and use it in following iterations of analysis during work inside modern IDEs. The method is implemented in a commercial product for MS Visual Studio. The result of implementation described method is reduced more that in ten times time needed to analyze changed source code. Such performance improvement allows to re-analyze code on every changed symbol inside IDE and issue defects found in source code on-the-fly while developer creates program. This method is implemented inside of product Klocwork inSight 9.5

About the Authors

V. O. Savitsky
ISP RAS
Russian Federation


D. V. Sidorov
ISP RAS
Russian Federation


References

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

2. S.V. Syromyatnikov. Deklarativnyj interfejs poiska defektov po sintaksicheskim derev'yam: yazyk KAST [Declarative Interface of Detecting Defects on Syntax Trees: KAST Language]. Trudy ISP RАN [The Proceedings of ISP RAS]. 2011, vol. 20, pp. 51-68 (in Russian).

3. MS Visual Studio precompiled headers http://msdn.microsoft.com/en- us/library/szfdksca(v=vs.71).aspx.

4. GCC Using precompiled headers http://gcc.gnu.org/onlinedocs/gcc/Precompiled- Headers.html.

5. Martin Fowler. Refactoring: Improving the Design of Existing Code.

6. Andrew Hunt and David Thomas The Pragmatic Programmer: From Journeyman to

7. Master Addison-Wesley, Oct 1999.

8. J.-M. Larcheveque Optimal Incremental Parsing ACM Transactions on Programming Languages and Systems, Vol. 17, No 1, January 1995.

9. Tim A. Wagner and Susan L. Graham Incremental Analysis of Real Programming Languages 1997 ACM.

10. Dashing Yeh, Uwe Kastens Automatic Construction of Incremental LR(1) Parsers

11. Carlo Ghezzi, Dino Mandrioli Incremental Parsing ACM Transactions on Programming Languages and Systems, Vol. 1, No. 1, July 1979.

12. Mats Wirdn Minimal Change and Bounded Incremental Parsing


Review

For citations:


Savitsky V.O., Sidorov D.V. Incremental source code analysis for C/C++ languages. Proceedings of the Institute for System Programming of the RAS (Proceedings of ISP RAS). 2012;22. (In Russ.)



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


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