Analysis of Include Dependencies in C++ Source Code

The C++ Standard Template Library (STL) is the flagship example for libraries based on the generic programming paradigm. The usage of this library is intended to minimize classical C/C++ errors, but does not warrant bug-free programs. Furthermore, many new kinds of errors may arise from the inaccurate use of the generic programming paradigm, like dereferencing invalid iterators or misunderstanding remove-like algorithms. Unfortunately, the C++ Standard does not define which standard header includes another standard headers. It is easy to write code that works perfectly on an implementation but fails to compile with another implementation of STL. These unportable codes should be result in compilation error with every STL implementation. However, in this case the compiler does not warn us that this code is erroneous. In this paper we present our tool that is based on the Clang. This tool is able to detect the missing include directives that are patched by the STL implementation’s internal structure. It also reports the unnecessary include directives to avoid extra compilation time. The background of our tool is discovered and we briefly present the underlying data structures and algorithms. We analyse how these problems occur in open source libraries and programs. Which environment proves oneself to be lazy or strict? How the developers take advantage of this portability issue?

[1]  Csaba Szabó,et al.  A closer look at software refactoring using symbolic execution , 2015 .

[2]  Yijun Yu,et al.  Removing false code dependencies to speedup software build processes , 2003, CASCON.

[3]  Jian Zhang,et al.  A Memory Model for Static Analysis of C Programs , 2010, ISoLA.

[4]  Thomas Ball,et al.  Static analysis tools as early indicators of pre-release defect density , 2005, ICSE.

[5]  Bjarne Stroustrup,et al.  The C++ Programming Language: Special Edition , 2000 .

[6]  Ute Dreher Generic Programming And The Stl Using And Extending The C Standard Template Library , 2016 .

[7]  Robert W. Bowdidge,et al.  Why don't software developers use static analysis tools to find bugs? , 2013, 2013 35th International Conference on Software Engineering (ICSE).

[8]  Norbert Pataki,et al.  Concurrent object construction in modern object-oriented programming languages , 2015 .

[9]  József Mihalicza How #includes Aect Build Time in Large Systems , 2010 .

[10]  Norbert Pataki,et al.  C/C++ Preprocessing with modern data storage devices , 2015, 2015 IEEE 13th International Scientific Conference on Informatics.

[11]  Norbert Pataki,et al.  Task-specific style verification , 2012 .

[12]  Zoltán Porkoláb,et al.  Automatic Checking of the Usage of the C++11 Move Semantics , 2015, Acta Cybern..

[13]  Norbert Pataki,et al.  Clang matchers for verified usage of the C++ Standard Template Library , 2015 .

[14]  Norbert Pataki,et al.  Source language representation of function summaries in static analysis , 2016, ICOOOLPS@ECOOP.

[15]  Norbert Pataki,et al.  Backward Compatibility Violations and their Detection in C++ Legacy Code using Static Analysis , 2016 .

[16]  Konstantin Serebryany,et al.  MemorySanitizer: Fast detector of uninitialized memory use in C++ , 2015, 2015 IEEE/ACM International Symposium on Code Generation and Optimization (CGO).

[17]  James C. King,et al.  Symbolic execution and program testing , 1976, CACM.