Skip to main content

Advertisement

SpringerLink
Log in
Menu
Find a journal Publish with us
Search
Cart
Book cover

International Conference on Compiler Construction

CC 2012: Compiler Construction pp 144–164Cite as

  1. Home
  2. Compiler Construction
  3. Conference paper
Object Model Construction for Inheritance in C++ and Its Applications to Program Analysis

Object Model Construction for Inheritance in C++ and Its Applications to Program Analysis

  • Jing Yang17,18,
  • Gogul Balakrishnan17,
  • Naoto Maeda19,
  • Franjo Ivančić17,
  • Aarti Gupta17,
  • Nishant Sinha20,
  • Sriram Sankaranarayanan21 &
  • …
  • Naveen Sharma22 
  • Conference paper
  • 1006 Accesses

  • 6 Citations

Part of the Lecture Notes in Computer Science book series (LNTCS,volume 7210)

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

  1. Apache. Xerces project, http://xerces.apache.org/

  2. 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)

    Google Scholar 

  3. Ball, T., Rajamani, S.K.: The SLAM project: debugging system software via static analysis. In: POPL, pp. 1–3 (2002)

    Google Scholar 

  4. Chandra, S., Fink, S.J., Sridharan, M.: Snugglebug: A powerful approach to weakest preconditions. In: PLDI, pp. 363–374 (2009)

    Google Scholar 

  5. Chen, J.: A typed intermediate language for compiling multiple inheritance. In: POPL (2007)

    Google Scholar 

  6. Clang static analyzer, http://clang-analyzer.llvm.org

  7. C++ support for Clang, http://clang-analyzer.llvm.org/dev_cxx.html (accessed January 6, 2012)

  8. 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)

    CrossRef  Google Scholar 

  9. Clarke Jr., E.M., Grumberg, O., Peled, D.A.: Model checking. MIT Press, Cambridge (1999)

    Google Scholar 

  10. Comeau C++ compiler, http://www.comeaucomputing.com

  11. Cousot, P., Cousot, R.: Static determination of dynamic properties of programs. In: Proc. 2nd. Int. Symp. on Programming, Paris (April 1976)

    Google Scholar 

  12. 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)

    Google Scholar 

  13. 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)

    CrossRef  Google Scholar 

  14. Cousot, P., Halbwachs, N.: Automatic discovery of linear constraints among variables of a program. In: POPL, pp. 84–96 (1978)

    Google Scholar 

  15. C++ frontend. Edison Design Group, NJ

    Google Scholar 

  16. Havelund, K., Pressburger, T.: Model checking java programs using java pathfinder. STTT 2(4), 366–381 (2000)

    MATH  Google Scholar 

  17. Hovemeyer, D., Pugh, W.: Finding more null pointer bugs, but not too many. In: PASTE, pp. 9–14 (2007)

    Google Scholar 

  18. 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)

    Google Scholar 

  19. Lattner, C.: LLVM: A compilation framework for lifelong program analysis and transformation. In: Int. Symp. on Code Generation and Optimization (2004)

    Google Scholar 

  20. 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)

    CrossRef  MATH  Google Scholar 

  21. Lieberman, H.: Using prototypical objects to implement shared behavior in object oriented systems. In: OOPSLA, pp. 214–223 (1986)

    Google Scholar 

  22. Miné, A.: The octagon abstract domain. In: Working Conf. on Rev. Eng. (2001)

    Google Scholar 

  23. NECLA verification benchmarks, http://www.nec-labs.com/research/system/systems_SAV-website/benchmarks.php

  24. 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)

    CrossRef  Google Scholar 

  25. Nokia. Qt: a cross-platform application and UI framework, http://qt.nokia.com/

  26. 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)

    CrossRef  Google Scholar 

  27. Quinlan, D.J.: Rose: Compiler support for object-oriented frameworks. Parallel Processing Letters 10(2/3), 215–226 (2000)

    CrossRef  Google Scholar 

  28. 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)

    Google Scholar 

  29. Ramananandro, T., Reis, G.D., Leroy, X.: Formal verification of object layout for C++ multiple inheritance. In: POPL (2011)

    Google Scholar 

  30. Rossie Jr., J.G., Friedman, D.P.: An algebraic semantics of subobjects. In: OOPSLA, pp. 187–199. ACM, New York (1995)

    Google Scholar 

  31. 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)

    CrossRef  Google Scholar 

  32. 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)

  33. Stroustrup, B.: Multiple inheritance for C++. Computing Systems 2(4), 367–395 (1989)

    Google Scholar 

  34. Stroustrup, B.: Evolving a language in and for the real world: C++ 1991-2006. In: Proc. of History of Programming Languages III (2007)

    Google Scholar 

  35. Sweeney, P.F., Burke, M.: Quantifying and evaluating the space overhead for alternative C++ memory layouts. Softw. Pract. Exper. 33(7), 595–636 (2003)

    CrossRef  MATH  Google Scholar 

  36. Sweeney, P.F., Gil, J.Y.: Space and time-efficient memory layout for multiple inheritance. In: OOPSLA. ACM, New York (1999)

    Google Scholar 

  37. Thirunarayan, K., Kniesel, G., Hampapuram, H.: Simulating multiple inheritance and generics in Java. Comp. Lang. 25(4), 189–210 (1999)

    CrossRef  MATH  Google Scholar 

  38. Tip, F., Sweeney, P.F.: Class hierarchy specialization. Acta. Inf. 36(12), 927–982 (2000)

    CrossRef  MathSciNet  MATH  Google Scholar 

  39. 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)

    Google Scholar 

  40. Xie, Y., Aiken, A.: Saturn: A scalable framework for error detection using boolean satisfiability. Trans. on Prog. Lang. and Syst. 29(3) (2007)

    Google Scholar 

Download references

Author information

Authors and Affiliations

  1. NEC Labs America, USA

    Jing Yang, Gogul Balakrishnan, Franjo Ivančić & Aarti Gupta

  2. University of Virginia, USA

    Jing Yang

  3. NEC Corporation, Japan

    Naoto Maeda

  4. IBM Research, India

    Nishant Sinha

  5. University of Colorado, Boulder, USA

    Sriram Sankaranarayanan

  6. NEC-HCL Tech., India

    Naveen Sharma

Authors
  1. Jing Yang
    View author publications

    You can also search for this author in PubMed Google Scholar

  2. Gogul Balakrishnan
    View author publications

    You can also search for this author in PubMed Google Scholar

  3. Naoto Maeda
    View author publications

    You can also search for this author in PubMed Google Scholar

  4. Franjo Ivančić
    View author publications

    You can also search for this author in PubMed Google Scholar

  5. Aarti Gupta
    View author publications

    You can also search for this author in PubMed Google Scholar

  6. Nishant Sinha
    View author publications

    You can also search for this author in PubMed Google Scholar

  7. Sriram Sankaranarayanan
    View author publications

    You can also search for this author in PubMed Google Scholar

  8. Naveen Sharma
    View author publications

    You can also search for this author in PubMed Google Scholar

Editor information

Editors and Affiliations

  1. School for Informatics, University of Edinburgh, 10 Crichton Street, EH8 9AB, Edinburgh, UK

    Michael O’Boyle

Rights and permissions

Reprints 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

  • .RIS
  • .ENW
  • .BIB
  • 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)

Share this paper

Anyone you share the following link with will be able to read this content:

Sorry, a shareable link is not currently available for this article.

Provided by the Springer Nature SharedIt content-sharing initiative

Search

Navigation

  • Find a journal
  • Publish with us

Discover content

  • Journals A-Z
  • Books A-Z

Publish with us

  • Publish your research
  • Open access publishing

Products and services

  • Our products
  • Librarians
  • Societies
  • Partners and advertisers

Our imprints

  • Springer
  • Nature Portfolio
  • BMC
  • Palgrave Macmillan
  • Apress
  • Your US state privacy rights
  • Accessibility statement
  • Terms and conditions
  • Privacy policy
  • Help and support

167.114.118.210

Not affiliated

Springer Nature

© 2023 Springer Nature