解析C ++源并将入头内联方法移动到.cpp源文件的工具? [英] Tool to parse C++ source and move in-header inline methods to the .cpp source file?

查看:178
本文介绍了解析C ++源并将入头内联方法移动到.cpp源文件的工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的应用程序的源代码是成千上万的行,成千上万的文件,在很多地方很老的应用程序是第一次写于1995年或1996年。在过去几年我的团队已大大提高了质量来源,但一个问题仍然是,特别是错误我:很多类有很多方法在头文件中完全定义。

The source code of our application is hundreds of thousands of line, thousands of files, and in places very old - the app was first written in 1995 or 1996. Over the past few years my team has greatly improved the quality of the source, but one issue remains that particularly bugs me: a lot of classes have a lot of methods fully defined in their header file.

我没有问题的方法声明内联在一些标题中 - 一个struct的构造函数,一个简单的方法,其中内联可测量使它更快(我们有一些数学函数这样)等等。但是,内联方法的自由使用没有明显的原因是:

I have no problem with methods declared inline in a header in some cases - a struct's constructor, a simple method where inlining measurably makes it faster (we have some math functions like this), etc. But the liberal use of inlined methods for no apparent reason is:

  • Messy
  • 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...)
  • Probably increases the compiled code size
  • 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.

最后一个原因可能是我们的问题,这是一个很好的理由通过代码库,并将大多数定义移动到源文件。

That last reason may now be causing problems for us and it's a good reason to go through the codebase and move most definitions to the source file.

我们的代码库是巨大的。 是否有自动化工具可以为我们执行(大部分)?

Our codebase is huge. Is there an automated tool that can do (most of) this for us?

注意:


  • 我们使用Embarcadero RAD Studio 2010.换句话说,C ++的方言包括 VCL和其他扩展程序等。

  • 一些标题是独立的,但大多数与一个相应的.cpp文件配对。除了扩展名,文件名是相同的,即如果有在X.h中定义的方法,它们可以移动到X.cpp。这也意味着工具不必处理解析整个项目 - 它可能只是解析单个对的.cpp / .h文件,忽略包含等,只要它可以可靠地识别一个方法与一个主体定义在类声明中移动它。

推荐答案

您可以尝试 Lazy C ++ 。我没有使用它,但我相信它是一个命令行工具,只是你想做的。

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.

这篇关于解析C ++源并将入头内联方法移动到.cpp源文件的工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆