From a29f54c1222a174e1b7ca72af3a881df2020f04d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 4 Dec 2010 15:52:22 +0100 Subject: [PATCH] Writing rules: Removed the C++ information. I'll focus on regular expressions to begin with. --- man/writing-rules.docbook | 71 +++++++-------------------------------- 1 file changed, 12 insertions(+), 59 deletions(-) diff --git a/man/writing-rules.docbook b/man/writing-rules.docbook index dd1090150..49e31b04f 100644 --- a/man/writing-rules.docbook +++ b/man/writing-rules.docbook @@ -64,7 +64,7 @@ The token lists are designed for rule matching. All redundant information is removed. A number of transformations are made - automatically on the token lists to simplify writing rules. + automatically on the token lists to simplify writing rules. The class Tokenizer create the token lists and perform all simplifications. @@ -169,18 +169,6 @@ http://cppcheck.sourceforge.net/doxyoutput/classTokenizer.html - -
- Reference - - There are many -
- - -
- Symbol database - - TODO: write more here.
@@ -205,7 +193,7 @@ <?xml version="1.0"?> <rule data="simple"> - <pattern> / 0</pattern> + <pattern>/ 0</pattern> <message> <id>divbyzero</id> <severity>error</severity> @@ -216,53 +204,18 @@ It is recommended that you use the simple token list whenever you can. If you need some information that is removed in it then try the normal token list. - -
- C++ + When you write the patterns remember that; - Advanced rules are created with C++. + + + tokens are always separated by spaces. "1+2" is not + possible. + - Here is a simple function that detects division by zero: - - void CheckDivByZero::check() -{ - // Scan through all tokens - for (const Token *tok = _tokens; tok; tok = tok->next()) { - // Match tokens to see if there is division with zero.. - if (Token::Match(tok, "/ 0")) { - // Division by zero found. Report error - reportError(tok); - } - } -} - - All rules must be encapsulated in classes. These classes must - inherit from the base class Check. - - It is also possible to inherit from - ExecutionPath, it provides better control-flow - analysis, but that is much more advanced. You should be a master on using - Check before you try to use - ExecutionPath. - - Adding your rules to Cppcheck is easy. Just make sure they are - linked with Cppcheck when it is compiled. Cppcheck will automatically use - all rules that are compiled into it. - - TODO: A full example? - - - - The recommendation is that you use the simple token list whenever - possible. Only use the normal token list when necessary. - - - - - - TODO: more descriptions - - + + there is no indentation, spaces, comments, line breaks. + +