Abstract
Modern object-oriented programming languages such as C++ provide convenient abstractions and data encapsulation mechanisms for software developers. However, these features also complicate testing and static analysis of programs that utilize object-oriented programming concepts. In particular, the C++ language exhibits features such as multiple inheritance, static and dynamic typecasting that make static analyzers for C++ quite hard to implement. In this paper, we present an approach where static analysis is performed by lowering the original C++ program into a semantically equivalent C program. However, unlike existing translation mechanisms that utilize complex pointer arithmetic operations, virtual-base offsets, virtual-function pointer tables, and calls to run-time libraries to model C++ features, our translation is targeted towards making static program analyzers for C++ easier to write and provide more precise results. We have implemented our ideas in a framework for C++ called CILpp that is analogous to the popular C Intermediate Language (CIL) framework. We evaluate the effectiveness of our translation in a bug finding tool that uses abstract interpretation and model checking. The bug finding tool uncovered several previously unknown bugs in C++ open source projects.
Keywords
- Model Check
- Base Class
- Class Hierarchy
- Access Path
- Multiple Inheritance
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.
Download conference paper PDF
References
Apache. Xerces project, http://xerces.apache.org/
Balakrishan, G., Maeda, N., Sankaranarayanan, S., Ivančić, F., Gupta, A., Pothengil, R.: Modeling and analyzing the interaction of C and C++ strings. In: Int. Conf. on Formal Verif. of Object-Oriented Software (2011)
Ball, T., Rajamani, S.K.: The SLAM project: debugging system software via static analysis. In: POPL, pp. 1–3 (2002)
Chandra, S., Fink, S.J., Sridharan, M.: Snugglebug: A powerful approach to weakest preconditions. In: PLDI, pp. 363–374 (2009)
Chen, J.: A typed intermediate language for compiling multiple inheritance. In: POPL (2007)
Clang static analyzer, http://clang-analyzer.llvm.org
C++ support for Clang, http://clang-analyzer.llvm.org/dev_cxx.html (accessed January 6, 2012)
Clarke, E., Kroning, D., Lerda, F.: A Tool for Checking ANSI-C Programs. In: Jensen, K., Podelski, A. (eds.) TACAS 2004. LNCS, vol. 2988, pp. 168–176. Springer, Heidelberg (2004)
Clarke Jr., E.M., Grumberg, O., Peled, D.A.: Model checking. MIT Press, Cambridge (1999)
Comeau C++ compiler, http://www.comeaucomputing.com
Cousot, P., Cousot, R.: Static determination of dynamic properties of programs. In: Proc. 2nd. Int. Symp. on Programming, Paris (April 1976)
Cousot, P., Cousot, R.: Abstract interpretation: A unified lattice model for static analysis of programs by construction of approximation of fixed points. In: POPL (1977)
Cousot, P., Cousot, R., Feret, J., Mauborgne, L., Miné, A., Monniaux, D., Rival, X.: The ASTREÉ Analyzer. In: Sagiv, M. (ed.) ESOP 2005. LNCS, vol. 3444, pp. 21–30. Springer, Heidelberg (2005)
Cousot, P., Halbwachs, N.: Automatic discovery of linear constraints among variables of a program. In: POPL, pp. 84–96 (1978)
C++ frontend. Edison Design Group, NJ
Havelund, K., Pressburger, T.: Model checking java programs using java pathfinder. STTT 2(4), 366–381 (2000)
Hovemeyer, D., Pugh, W.: Finding more null pointer bugs, but not too many. In: PASTE, pp. 9–14 (2007)
Ivančić, F., Shlyakhter, I., Gupta, A., Ganai, M., Kahlon, V., Wang, C., Yang, Z.: Model checking C programs using F-Soft. In: IEEE International Conference on Computer Design, pp. 297–308 (October 2005)
Lattner, C.: LLVM: A compilation framework for lifelong program analysis and transformation. In: Int. Symp. on Code Generation and Optimization (2004)
Leavens, G.T., Leino, K.R.M., Müller, P.: Specification and verification challenges for sequential object-oriented programs. Formal Asp. Comput. 19(2), 159–189 (2007)
Lieberman, H.: Using prototypical objects to implement shared behavior in object oriented systems. In: OOPSLA, pp. 214–223 (1986)
Miné, A.: The octagon abstract domain. In: Working Conf. on Rev. Eng. (2001)
NECLA verification benchmarks, http://www.nec-labs.com/research/system/systems_SAV-website/benchmarks.php
Necula, G.C., McPeak, S., Rahul, S.P., Weimer, W.: CIL: Intermediate Language and Tools for Analysis and Transformation of C Programs. In: CC 2002. LNCS, vol. 2304, pp. 213–228. Springer, Heidelberg (2002)
Nokia. Qt: a cross-platform application and UI framework, http://qt.nokia.com/
Prabhu, P., Maeda, N., Balakrishnan, G., Ivančić, F., Gupta, A.: Interprocedural Exception Analysis for C++. In: Mezini, M. (ed.) ECOOP 2011. LNCS, vol. 6813, pp. 583–608. Springer, Heidelberg (2011)
Quinlan, D.J.: Rose: Compiler support for object-oriented frameworks. Parallel Processing Letters 10(2/3), 215–226 (2000)
Ramalingam, G., Srinivasan, H.: A member lookup algorithm for C++. In: SIGPLAN Conf. on Prog. Lang. Design and Impl., pp. 18–30. ACM, New York (1997)
Ramananandro, T., Reis, G.D., Leroy, X.: Formal verification of object layout for C++ multiple inheritance. In: POPL (2011)
Rossie Jr., J.G., Friedman, D.P.: An algebraic semantics of subobjects. In: OOPSLA, pp. 187–199. ACM, New York (1995)
Sankaranarayanan, S., Ivančić, F., Gupta, A.: Program Analysis Using Symbolic Ranges. In: Riis Nielson, H., Filé, G. (eds.) SAS 2007. LNCS, vol. 4634, pp. 366–383. Springer, Heidelberg (2007)
C. standards commitee. Working draft, standard for C++, http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf (accessed January 6, 2012)
Stroustrup, B.: Multiple inheritance for C++. Computing Systems 2(4), 367–395 (1989)
Stroustrup, B.: Evolving a language in and for the real world: C++ 1991-2006. In: Proc. of History of Programming Languages III (2007)
Sweeney, P.F., Burke, M.: Quantifying and evaluating the space overhead for alternative C++ memory layouts. Softw. Pract. Exper. 33(7), 595–636 (2003)
Sweeney, P.F., Gil, J.Y.: Space and time-efficient memory layout for multiple inheritance. In: OOPSLA. ACM, New York (1999)
Thirunarayan, K., Kniesel, G., Hampapuram, H.: Simulating multiple inheritance and generics in Java. Comp. Lang. 25(4), 189–210 (1999)
Tip, F., Sweeney, P.F.: Class hierarchy specialization. Acta. Inf. 36(12), 927–982 (2000)
Wasserrab, D., Nipkow, T., Snelting, G., Tip, F.: An operational semantics and type safety proof for multiple inheritance in C++. In: OOPSLA, pp. 345–362. ACM Press (2006)
Xie, Y., Aiken, A.: Saturn: A scalable framework for error detection using boolean satisfiability. Trans. on Prog. Lang. and Syst. 29(3) (2007)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2012 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Yang, J. et al. (2012). Object Model Construction for Inheritance in C++ and Its Applications to Program Analysis. In: O’Boyle, M. (eds) Compiler Construction. CC 2012. Lecture Notes in Computer Science, vol 7210. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-28652-0_8
Download citation
DOI: https://doi.org/10.1007/978-3-642-28652-0_8
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-28651-3
Online ISBN: 978-3-642-28652-0
eBook Packages: Computer ScienceComputer Science (R0)
