没有合适的资源?快使用搜索试试~ 我知道了~
首页cppcheck的规则书写教材2.pdf
资源详情
资源评论
资源推荐

1
Writing Cppcheck rules
Part 2 - The Cppcheck data representation
Daniel Marjamäki, Cppcheck
2010
Introduction
In this article I will discuss the data representation that Cppcheck uses.
The data representation that Cppcheck uses is specifically designed for static analysis. It is not intended
to be generic and useful for other tasks.
See the data
There are two ways to look at the data representation at runtime.
Using --rule=.+ is one way. All tokens are written on a line:
int a ; int b ;
Using --debug is another way. The tokens are line separated in the same way as the original code:
1: int a@1 ;
2: int b@2 ;
In the --debug output there are "@1" and "@2" shown. These are the variable ids (Cppcheck gives each
variable a unique id). You can ignore these if you only plan to write rules with regular expressions, you
can't use variable ids with regular expressions.
In general, I will use the --rule=.+ output in this article because it is more compact.
Some of the simplifications
The data is simplified in many ways.
Preprocessing
The Cppcheck data is preprocessed. There are no comments, #define, #include, etc.
Original source code:
#define SIZE 123
char a[SIZE];
The Cppcheck data for that is:
char a [ 123 ] ;
typedef
The typedefs are simplified.












安全验证
文档复制为VIP权益,开通VIP直接复制

评论0