Parsing C/C plus plus Code without Pre-processing

被引:0
|
作者
Padioleau, Yoann [1 ]
机构
[1] Univ Illinois, Urbana, IL USA
来源
关键词
D O I
暂无
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
It is difficult to develop style-preserving source-to-source transformation engines for C and C++. The main reason is not the complexity of those languages, but the use of the C pre-processor (cpp), especially ifdefs and macros. This has for example hindered the development of refactoring tools for C and C++. In this paper we propose to combine multiple techniques and heuristics to parse C/C++ source files as-is, while still having only a few modifications to the original grammars of C and C++. We rely on the fact that in most C and C++ software, programmers follow a limited number of conventions on the use of cpp which makes it possible to disambiguate different situations by just looking at the context, names, or indentation of cpp constructs. We have implemented a parser, Yacfe, based on these techniques and evaluated it on 16 large open source projects. Yacfe can on average parse 96% of those projects correctly. As a side effect, we also found mistakes in code that was not compiled because it was protected by particular ifdefs, but that was still analyzed by Yacfe. Using Yacfe on new projects may require adapting some of our techniques. We found that as conventions and idioms are shared by many projects, the adaptation time is on average less than 2 hours for a new project.
引用
收藏
页码:109 / 125
页数:17
相关论文
共 50 条
  • [1] Bridging Excel and C/C plus plus Code
    Punuru, Janardhana R.
    Knopf, F. Carl
    [J]. COMPUTER APPLICATIONS IN ENGINEERING EDUCATION, 2008, 16 (04) : 289 - 304
  • [2] Analysis and Code Model Extraction for C/C plus plus Source Code
    Wagner, Christian
    Margaria, Tiziana
    Pagendarm, Hans-Georg
    [J]. 2009 14TH IEEE INTERNATIONAL CONFERENCE ON ENGINEERING OF COMPLEX COMPUTER SYSTEMS (ICECCS), 2009, : 110 - +
  • [3] A C/C plus plus Code Vulnerability Dataset with Code Changes and CVE Summaries
    Fan, Jiahao
    Li, Yi
    Wang, Shaohua
    Nguyen, Tien N.
    [J]. 2020 IEEE/ACM 17TH INTERNATIONAL CONFERENCE ON MINING SOFTWARE REPOSITORIES, MSR, 2020, : 508 - 512
  • [4] A Study of C/C plus plus Code Weaknesses on Stack Overflow
    Zhang, Haoxiang
    Wang, Shaowei
    Li, Heng
    Chen, Tse-Hsun
    Hassan, Ahmed E.
    [J]. IEEE TRANSACTIONS ON SOFTWARE ENGINEERING, 2021, 48 (07) : 2359 - 2375
  • [5] C plus plus EDSL for parallel code generation
    Berenyi, Daniel
    [J]. PROCEEDINGS 2015 8TH ROMANIA TIER 2 FEDERATION GRID, CLOUD & HIGH PERFORMANCE COMPUTING IN SCIENCE (RO-LCG), 2015,
  • [6] Vulnerable C/C plus plus Code Usage in IoT Software Systems
    Alnaeli, Saleh M.
    Sarnowski, Melissa
    Aman, Md Sayedul
    Abdelgawad, Ahmed
    Yelamarthi, Kumar
    [J]. 2016 IEEE 3RD WORLD FORUM ON INTERNET OF THINGS (WF-IOT), 2016, : 348 - 352
  • [7] MegaVul: A C/C plus plus Vulnerability Dataset with Comprehensive Code Representations
    Ni, Chao
    Shen, Liyu
    Yang, Xiaohu
    Zhu, Yan
    Wang, Shaohua
    [J]. 2024 IEEE/ACM 21ST INTERNATIONAL CONFERENCE ON MINING SOFTWARE REPOSITORIES, MSR, 2024, : 738 - 742
  • [8] Interactive C plus plus code development using C plus plus Explorer and GitHub classroom for educational purposes
    Diehl, Patrick
    Brandt, Steven R.
    [J]. CONCURRENCY AND COMPUTATION-PRACTICE & EXPERIENCE, 2023, 35 (18):
  • [9] Enforcing Techniques and Transformation of C/C plus plus Source Code to Heterogeneous Hardware
    Gyimesi, Gabor
    Ban, Denes
    Siket, Istvan
    Ferenc, Rudolf
    Brugnoni, Silvano
    Corbat, Thomas
    Sommerlad, Peter
    Suter, Toni
    [J]. 2016 INT IEEE CONFERENCES ON UBIQUITOUS INTELLIGENCE & COMPUTING, ADVANCED & TRUSTED COMPUTING, SCALABLE COMPUTING AND COMMUNICATIONS, CLOUD AND BIG DATA COMPUTING, INTERNET OF PEOPLE, AND SMART WORLD CONGRESS (UIC/ATC/SCALCOM/CBDCOM/IOP/SMARTWORLD), 2016, : 1173 - 1180
  • [10] Techniques for Memory-Efficient Model Checking of C and C plus plus Code
    Rockai, Petr
    Still, Vladimir
    Barnat, Jiri
    [J]. SOFTWARE ENGINEERING AND FORMAL METHODS, 2015, 9276 : 268 - 282