SPrinter
1.0.0
用于查找C ++程序中智能指针错误的静态检查器
用于检测C ++智能指针API滥用的静态编码样式检查器,可能会导致内存错误,例如内存泄漏,免费后使用并双免费使用。
报告STL容器中使用的auto_ptr模板参数。
std::vector<std::auto_ptr< int >> vi;
^
Warn here报告从一个auto_ptr到另一个自动_ptr的所有内存传输。
std::auto_ptr< int > p1 ( new int ( 42 ));
void foo (std::auto_ptr< int > p);
foo (p1);
^
Warn here报告从智能指针观察者中delete指针的操作。
std::unique_ptr< int > p = std::make_unique< int >( 42 );
delete p.get();
^
Warn here用未分配的内存报告启动。
int I;
std::unique_ptr< int > p (&I);
^
Warn here在没有复制构造函数和分配运算符的类中,在类中报告一个私有的auto_ptr字段。
class Type {
private:
std::auto_ptr< int > p;
^
Warn here
};报告具有原始指针变量的智能指针的构造。
void foo ( int *p) {
std::unique_ptr< int > sp (p);
^
Warn here
}报告智能指针构造的不匹配类型的模板参数和new操作员。
std::auto_ptr< int > sp ( new int [ 42 ]);
^
Warn here报告未选中的锁定weak_ptr s的用法。
std::weak_ptr< int > wp;
...
*wp.lock() = 42 ;
^
Warn here报告未交易的release D指针。
std::unique_ptr< int > sp;
...
*sp.release() = 42 ;
^
Warn here带有短跑运动员(SHA256SUM 2C237C9A7E280F91D705ED6E16189C0A63B17643B17643F09F09F09F09F3E23E23B2F7E6ECCCC712272)的Clang-Tidy
如果您需要源代码,请与我们联系。
smartpointersafety-前缀。例如
$ clang-tidy -checks= ' -*,smartpointersafety-* ' source.cpp