什么是cppcheck规则文件< pattern>句法? [英] What is cppcheck rule-file <pattern> syntax?

查看:415
本文介绍了什么是cppcheck规则文件< pattern>句法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经闲逛了一段时间,在任何地方都找不到。我找到了一个显示简单模式的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规则文件&lt; pattern&gt;句法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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