gpt4 book ai didi

qt - 安静的 clang

转载 作者:行者123 更新时间:2023-12-04 20:33:23 26 4
gpt4 key购买 nike

我有一个通过 cmake 使用 clang-tidy 的构建:

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

在构建它时,我在 Qt 库中发现了可能的内存泄漏:
/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),
^

我怎样才能让这个安静下来?

我已经尝试过的:
  • 添加 // NOLINT到 a.cpp:33 的结尾 -> 无效
  • 添加 // NOLINT到 qobject.h:242 的末尾 -> 无效
  • 将 qobject.h:242 包裹在 #ifndef __clang_analyzer__ 中-> 无效
  • 将所有 qobject.h 包裹在 #ifndef __clang_analyzer__ 中-> 无效
  • 添加 // NOLINT到 connectImpl -> clang-tidy 崩溃的所有行

  • @塔罗德:
    这是我目前拥有的:
    #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__

    最佳答案

    我认为您必须评论所有 5 行 connectImpl() 或自 // NOLINT 以来的类似内容仅影响单个代码行。 (1)

    关于qt - 安静的 clang ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40642307/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com