0

I have created the following rule file for cpp check:

<?xml version="1.0"?>
<rule version="1">
<pattern>virtual .* \( .*dword .* \)</pattern>
<message>
<id>virtual function</id>
<summary>Possible error </summary>
</message>
</rule>

This rule is detecting only the first matching item in the code what will be the problem.

neontapir
  • 4,698
  • 3
  • 37
  • 52
Aswin Mc
  • 1
  • 1
  • It's unclear what you're asking here, so please explain your problem in more detail with examples. But for a start, try to replace every `.*` in your pattern with `.*?` – Lucas Trzesniewski Jul 10 '15 at 10:45
  • using this pattern am able to get the virtual function with dword parameter in my code but it only detect once even though there is several virtual functions with dword parameter if we comment first one thge next one will be getting – Aswin Mc Jul 13 '15 at 12:17

1 Answers1

0

I am a Cppcheck developer.

I am not sure .. but if pcre is greedy then the match will contain all code from the first virtual function, until the very last ')' in your code.

don't use .* , maybe [^)]* works better.

If you use --rule on the command line you can see what it matches.

Daniel Marjamäki
  • 2,907
  • 15
  • 16