SPrinter
1.0.0
C ++プログラムでスマートポインターエラーを見つけるための静的チェッカー
C ++スマートポインターのAPI誤用を検出するための静的なコーディングスタイルチェッカー。これは、メモリリーク、フリー後、ダブルフリーなどのメモリエラーにつながる可能性があります。
STLコンテナで使用されるauto_ptrテンプレート引数を報告します。
std::vector<std::auto_ptr< int >> vi;
^
Warn hereすべてのメモリ転送を、あるauto_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 hereSprinterとClang-Tidy(Sha256Sum 2C237C9A7E280F91D705ED6E16189C0A63B17643F09F3E2333B2F7E6ECCCC712272)
ソースコードが必要な場合は、お問い合わせください。
smartpointersafety-プレフィックスを有効にしてください。例えば
$ clang-tidy -checks= ' -*,smartpointersafety-* ' source.cpp