2016-11-16 17 views
5

Ben cmake ile çınlama-düzenli kullanan bir yapı vardır:susturma clang-düzenli

set_target_properties(project 
    PROPERTIES 
    ... 
    CXX_CLANG_TIDY 
     "/usr/bin/clang-tidy" 
     "-checks=modernize-*,readability-*,performance-*" 
     "-fix" 
) 

Qt kütüphaneleri içindeki olası bir bellek sızıntısı alıyorum bunu inşa ederken:

/opt/Qt5.7.0/5.7/gcc_64/include/QtCore/qobject.h:242:16: warning: Potential memory leak [clang-analyzer-cplusplus.NewDeleteLeaks] 
     return connectImpl(sender, reinterpret_cast<void **>(&signal), 
      ^
.../a.cpp:27:5: note: Taking false branch 
    if (not inputQFile.makeAbsolute()) { 
    ^
.../a.cpp:33:5: note: Calling 'QObject::connect' 
    connect(this, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), 
    ^
/opt/Qt5.7.0/5.7/gcc_64/include/QtCore/qobject.h:238:13: note: Left side of '||' is false 
     if (type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection) 
      ^
/opt/Qt5.7.0/5.7/gcc_64/include/QtCore/qobject.h:238:9: note: Taking false branch 
     if (type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection) 
     ^
/opt/Qt5.7.0/5.7/gcc_64/include/QtCore/qobject.h:242:16: note: Potential memory leak 
     return connectImpl(sender, reinterpret_cast<void **>(&signal), 
      ^

Nasıl Bunu susturuyorum?

Zaten çalıştığım şey:

  1. a.cpp sonuna bir // NOLINT ekleyin:> hiçbir etkisi -: - 242 33> etkisiz
  2. qobject.h sonuna bir // NOLINT ekle
  3. Wrap qobject.h: 242 bir #ifndef __clang_analyzer__ -> hiçbir etkisi
  4. Wrap qobject.h tümünün #ifndef __clang_analyzer__ -> etkisiz
  5. connecti tüm hatlara // NOLINT ekle mpl -> @Tarod

clang-düzenli çöker:

#ifndef __clang_analyzer__ 
     return connectImpl(sender, reinterpret_cast<void **>(&signal), 
          receiver, reinterpret_cast<void **>(&slot), 
          new QtPrivate::QSlotObject<Func2, typename QtPrivate::List_Left<typename SignalType::Arguments, SlotType::ArgumentCount>::Value, // NOLINT 
              typename SignalType::ReturnType>(slot), 
          type, types, &SignalType::Object::staticMetaObject); // NOLINT 
#endif //__clang_analyzer__ 
+0

'#ifndef __clang_analyzer__' çalışması gerekir. 'Qobject.h' dosyasının sonundaki' # endif' yazılıyor mu? – Tarod

+0

@Tarod Soruyu – Mac

+0

güncelledim Eğer 'qobject.h' dosyasının başında #ifndef __clang_analyzer__' komutunu koyarsanız? – Tarod

cevap

2

Sana // NOLINT beri connectImpl() nasıl 5 hatlarının tamamının veya benzer etkiler yorumlamak gerekir düşünüyorum: Burada Şu anda ne var sadece tek bir kod satırı.

+0

Clang-düzenli çökmelerimi yaparsam ... '/ usr/bin/clang-tidy' hatası ' – Mac

+1

muahaha'nın çalıştırılması, iyi test edilmiş bir araç gibi görünüyor ...;) En son sürümünü kullanıyor musunuz? – falkb

+0

Yup En son sürümü kullandım. 3.9.1 – Mac