【问题标题】:Cppcheck generate xml dump filecppcheck 生成 xml 转储文件
【发布时间】:2020-02-25 02:22:25
【问题描述】:

我正在尝试在 cppcheck 中使用 xml 转储文件来创建我的规则。当我查看运行 cppcheck 时生成的转储文件时,我看到标记 rawtokens 具有列表文件相关和文件中的原始数据。

<rawtokens>
<file index="0" name="qtProject/untitled1/teststatistic.cpp"/>
<file index="1" name="qtProject/untitled1/teststatistic.h"/>

但我只看到原始数据 fileIndex = 0

<tok fileIndex="0" linenr="1" column="1" str="#"/>
<tok fileIndex="0" linenr="1" column="2" str="include"/>
<tok fileIndex="0" linenr="1" column="10" str="&quot;teststatistic.h&quot;"/>
<tok fileIndex="0" linenr="4" column="1" str="TestStatistic"/>
<tok fileIndex="0" linenr="4" column="14" str="::"/>
<tok fileIndex="0" linenr="4" column="16" str="TestStatistic"/>
<tok fileIndex="0" linenr="4" column="29" str="("/>
<tok fileIndex="0" linenr="4" column="30" str=")"/>
<tok fileIndex="0" linenr="5" column="1" str="{"/>
<tok fileIndex="0" linenr="7" column="1" str="}"/>
</rawtokens>

cppcheck 中是否有任何选项可以显示 rawtokens 中所有文件列表中的原始数据?

命令我生成文件转储: cppcheck --dump teststatistic.cpp

【问题讨论】:

  • 当我在文件 cppcheck.cpp 中查看源代码 cppcheck 时,函数 checkFile。似乎没有列出所有原始数据的选项。那么如何更改源代码以显示所有原始数据。谢谢。

标签: c++ xml cppcheck


【解决方案1】:

cppcheck 为命令行中列出的每个输入文件生成一个.dump 文件。因此,当您执行cppcheck --dump teststatistic.cpp 时,您会得到teststatistic.cpp.dump 作为输出。

您可以使用cppcheck --language=c++ --dump teststatistic.cpp teststatistic.h 获取.cpp.h 文件的转储文件。或者您可以调用cppcheck 两次,一次用于.cpp 文件,一次用于.h 文件。无论哪种方式,您都可以从相应的.dump 文件中获取每个输入文件的原始数据。

注意cppcheck 知道.cpp 文件是c++,但不知道.h 文件是c++。所以,在处理.h文件时,必须在命令行中指定语言。

【讨论】:

  • 感谢您的解决方案。我已经解决了我的问题,使用 bash 检查文件夹中的所有文件
猜你喜欢
  • 2012-05-23
  • 1970-01-01
  • 1970-01-01
  • 2011-12-05
  • 1970-01-01
  • 2011-10-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多