Tool to parse C++ source and move in-header inline methods to the .cpp source file? [closed]

♀尐吖头ヾ 提交于 2019-11-30 18:46:43

You might try Lazy C++. I have not used it, but I believe it is a command line tool to do just what you want.

If the code is working then I would vote against any major automated rewrite.
Lots of work could be involved fixing it up.

Small iterative improvements over time is a better technique as you will be able to test each change in isolation (and add unit tests). Anyway your major complaint about not being able to find the code is not a real problem and is already solved. There are already tools that will index your code base so your editor will jump to the correct function definition without you having to search for it. Take a look at ctags or the equivalent for your editor.

  • Messy

    Subjective

  • Makes it hard to find the implementation of a method (especially searching through a tree of classes for a virtual function, only to find one class had its version declared in the header...)

    There are already tools available for finding the function. ctags will make a file that allows you to jump directly to the function from any decent editor (vim/emacs). I am sure your editor if nto one of these has the equivalent tool.

  • Probably increases the compiled code size

    Unlikely. The compiler will choose to inline or not based on internal metrics not weather it is marked inline in the source.

  • Probably causes issues for our linker, which is notoriously flaky for large codebases. To be fair, it has got much better in the past few years, but it's not perfect.

    Unlikely. If your linker is flakey then it is flakey it is not going to make much difference where the functions are defined as this has no bearing on if they are inlined anyway.

XE2 includes a new static analyzer. It might be worthwhile to give the new version of C++Builer's trial a spin.

Ira Baxter

You have a number of problems to solve:

  • How to regroup the source and header files ideally
  • How to automate the code modifications to carry this out

In both cases, you need a robust C++ parser with full name resolution to determine the dependencies accurately.

Then you need machinery that can reliably modify the C++ source code.

Our DMS Software Reengineering Toolkit with its C++ Front End could be used for this. DMS has been used for large-scale C++ code restructuring; see http://www.semdesigns.com/Company/Publications/ and track down the first paper "Case Study: Re-engineering C++ Component Models Via Automatic Program Transformation". (There's an older version of this paper you can download from there, but the published one is better). AFAIK, DMS is the only tool to have ever been applied to transforming C++ on large scale.

This SO discussion on reorganizing code addresses the problem of grouping directly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!