1

我正在寻找一个免费的软件、工具、库或任何分析 C++ 代码的东西。

据我所知,诸如“Cppcheck”之类的“静态代码分析”工具对我没有帮助,因为我无法定义自己的规则或输出。我猜,一个能给我一个 C++ 文件的 AST(抽象语法树)的库是最好的。

我的目标是编写一个命令行工具来生成包含以下内容的输出:

Test.cpp:
The file contains 42 global Integers.
The Class Test has the following attributes:
  String name,
  Int size.
The Class Test contains the following global functions:
  void Test(),
  int getTestSize(),
  String renameTest(String newName).
4

2 回答 2

5

You can use clang and the existing analyzer or implement your own analyzer on top of the provided APIs.

于 2012-06-08T13:20:47.893 回答
0

正如大卫建议 Clang 是一个不错的选择,您只需实现自己的 ASTConsumer ,您可以以已经存在的 clang ASTConsumers 为例,例如 ASTPrinter 或 ASTDumpXML

于 2012-10-09T11:53:21.117 回答