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