什么是cppcheck规则文件< pattern>句法? [英] What is cppcheck rule-file <pattern> syntax?
问题描述
我已经闲逛了一段时间,在任何地方都找不到。我找到了一个显示简单模式的cppcheck规则文件的好例子;
I've poked around for a while, and can't find this anywhere. I have found a nice example of a cppcheck rule-file that shows a simple pattern;
<?xml version="1.0"?>
<rule version="1">
<pattern>if \( p \) { free \( p \) ; }</pattern>
<message>
<id>redundantCondition</id>
<severity>style</severity>
<summary>Redundant condition. It is valid to free a NULL pointer.</summary>
</message>
</rule>
只要所有指针都命名为 p且调用是免费的,这可以很好地工作'。如何更改 p以匹配任何标识符?如何检查免费或删除?该模式是grep / awk / sed模式吗?
Which works nicely, as long as all the pointers are named 'p' and the call is 'free'. How do I change 'p' to match any identifier? How do I check for "'free' or 'delete'"? Is the pattern a grep/awk/sed pattern?
推荐答案
我是Cppcheck开发人员。
I am a Cppcheck developer.
Cppcheck使用 PCRE 。因此,请使用遵循Perl规则的正则表达式。
Cppcheck uses PCRE. So use a regular expression that follows the Perl rules.
我不太擅长Perl正则表达式,因此我无法回答如何/是否可以匹配任何标识符(因为它应该被匹配两次)。
I'm not really good at Perl regular expressions so I can't answer how/if you can match any identifier (since it should be matched twice).
..希望至少能有所帮助。
.. hope that helps a little at least.
这篇关于什么是cppcheck规则文件< pattern>句法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!