McSAF: A Static Analysis Framework for MATLAB

  • Jesse Doherty
  • Laurie Hendren
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7313)


Matlab is an extremely popular programming language used by scientists, engineers, researchers and students world-wide. Despite its popularity, it has received very little attention from compiler researchers. This paper introduces McSaf, an open-source static analysis framework which is intended to enable more compiler research for Matlab and extensions of Matlab. The framework is based on an intermediate representation (IR) called McLast, which has been designed to capture all the key features of Matlab, while at the same time being simple for program analysis. The paper describes both the IR and the procedure for creating the IR from the higher-level AST. The analysis framework itself provides visitor-based traversals including fixed-point-based traversals to support both forwards and backwards analyses. McSaf has been implemented as part of the McLab project, and the framework has already been used for a variety of analyses, both for Matlab and the AspectMatlab extension.


Analysis Framework Assignment Statement Node Type Intermediate Representation Class Hierarchy 
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.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
  2. 2.
  3. 3.
  4. 4.
    Almási, G., Padua, D.: MaJIC: compiling MATLAB for speed and responsiveness. In: Proceedings of the ACM SIGPLAN 2002 Conference on Programming Language Design and Implementation, pp. 294–303. ACM, New York (2002)CrossRefGoogle Scholar
  5. 5.
    Casey, A., Hendren, L.: MetaLexer: A modular lexical specification language. In: AOSD, pp. 7–18 (2011)Google Scholar
  6. 6.
    Chevalier-Boisvert, M., Hendren, L., Verbrugge, C.: Optimizing Matlab through Just-In-Time Specialization. In: Gupta, R. (ed.) CC 2010. LNCS, vol. 6011, pp. 46–65. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  7. 7.
    Derose, L., De Rose, L., Gallivan, K., Gallivan, K., Gallopoulos, E., Gallopoulos, E., Marsolf, B., Marsolf, B., Padua, D., Padua, D.: FALCON: A MATLAB Interactive Restructuring Compiler. In: Huang, C.-H., Sadayappan, P., Banerjee, U., Gelernter, D., Nicolau, A., Padua, D.A. (eds.) LCPC 1995. LNCS, vol. 1033, pp. 269–288. Springer, Heidelberg (1996)CrossRefGoogle Scholar
  8. 8.
    Doherty, J.: McSAF: An extensible static analysis framework for the MATLAB language. Master’s thesis. McGill University (December 2011)Google Scholar
  9. 9.
    Doherty, J., Hendren, L., Radpour, S.: Kind analysis for MATLAB. In: OOPSLA (2011)Google Scholar
  10. 10.
    Dubrau, A.: Taming MATLAB. Master’s thesis. McGill University (April 2012)Google Scholar
  11. 11.
    Ekman, T., Hedin, G.: The JastAdd extensible Java compiler. In: OOPSLA 2007: Proceedings of the 22nd Annual ACM SIGPLAN Conference on Object-Oriented Programming Systems and Applications, pp. 1–18. ACM, New York (2007)CrossRefGoogle Scholar
  12. 12.
    Ekman, T., Hedin, G.: The JastAdd system – modular extensible compiler construction. Science of Computer Programming 69(1-3), 14–26 (2007)MathSciNetzbMATHCrossRefGoogle Scholar
  13. 13.
    Joisha, P.G.: A Type Inferenence System for MATLAB with Applications to Code Optimization. Ph.D. thesis, Northwestern University (2003)Google Scholar
  14. 14.
    Joisha, P.G., Banerjee, P.: The MAGICA Type Inference Engine for MATLAB. In: Hedin, G. (ed.) CC 2003. LNCS, vol. 2622, pp. 121–125. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  15. 15.
    Lattner, C., Adve, V.: LLVM: a compilation framework for lifelong program analysis and transformation. In: CGO, pp. 75–88 (2004)Google Scholar
  16. 16.
    Li, J.: McFor: A MATLAB to FORTRAN 95 compiler. Master’s thesis. McGill University (August 2009)Google Scholar
  17. 17.
    Nilsson-Nyman, E., Hedin, G., Magnusson, E., Ekman, T.: Declarative intraprocedural flow analysis of Java source code. Electron. Notes Theor. Comput. Sci. 238, 155–171 (2009)CrossRefGoogle Scholar
  18. 18.
    Radpour, S.: Understanding and Refactoring MATLAB. Master’s thesis, McGill University (April 2012)Google Scholar
  19. 19.
    Rose, L.D., Padua, D.: Techniques for the translation of MATLAB programs into Fortran 90. ACM Trans. Program. Lang. Syst. 21(2), 286–323 (1999)CrossRefGoogle Scholar
  20. 20.
    Toheed Aslam, A.D., Doherty, J., Hendren, L.: AspectMatlab: An aspect-oriented scientific programming language. In: AOSD, pp. 181–192 (March 2010)Google Scholar
  21. 21.
    Vallée-Rai, R., Gagnon, E.M., Hendren, L., Lam, P., Pominville, P., Sundaresan, V.: Optimizing Java Bytecode Using the Soot Framework: Is It Feasible? In: Watt, D.A. (ed.) CC 2000. LNCS, vol. 1781, pp. 18–34. Springer, Heidelberg (2000)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2012

Authors and Affiliations

  • Jesse Doherty
    • 1
  • Laurie Hendren
    • 1
  1. 1.School of Computer ScienceMcGill UniversityMontrealCanada

Personalised recommendations