Ir al contenido

Clazy

Categorías:   Desarrollo
Captura de pantalla de Clazy
Clazy es un complemento del compilador clang que emite advertencias relacionadas con las prácticas adecuadas de Qt.
Instalar en
Linux
Este botón solo funciona con Discover y otras tiendas de aplicaciones AppStream. También puede usar el gestor de paquetes de su distribución.

Lanzamientos RSS

1.17.1 2026-03-22

Esta versión corrige el siguiente fallo:

  • fully-qualified-moc-types: Se ha corregido la regresión de falsos positivos para los tipos de puntero/referencia en genéricos.
1.16.1 2026-03-22

Lanzamiento que contiene parches para corregir los problemas de integración de QtCreator y

la compatibilidad con nuevas versiones de Qt. Este lanzamiento es compatible con las versiones 19 a 21 de LLVM.

Esta versión corrige los siguientes fallos:

  • Los diagnósticos se emiten siempre, incluso si no contienen correcciones. Esto se usa
  • para la integración en los IDE donde el proceso clazy escribe un archivo YAML que contiene
  • los mensajes, los intervalos y correcciones opcionales.
  • Ajustar la comprobación readlock-detaching para que funcione correctamente con los cambios de Qt 6.11.
1.17 2026-02-15

Esta versión corrige los siguientes fallos:

  • Se ha corregido la comprobación non-pod-static que emitía una advertencia para cada entrada de un contenedor.
  • Se ha corregido que use-arrow-operator-instead-of-data emitiera un falso positivo cuando el valor está moldeado.
  • No incluir QVariant en la lista blanca para detaching-temporary. QVariant::toString proporcionará un QString que no está desvinculado.
  • Hacer que detaching-temporary compruebe las condiciones correctamente cuando se encadenan más de dos llamadas a métodos.
  • Las correcciones para detaching-temporary/detaching-member son más fiables con intervalos de correcciones para llamadas de operador.
  • Cuando se usa QT_NAMESPACE, clazy maneja correctamente las clases de Qt que estén en dicho espacio de nombres.
  • Corrección para el método de sustitución erróneo para QMap::operator[]
  • Hacer el proyecto compatible con LLVM22. Se han corregido qhash-namespace, fully-qualified-moc-types y old-style-connect tests.
  • Ajustar la comprobación readlock-detaching para que funcione correctamente con los cambios de Qt 6.11.
  • Se ha movido qstring-ref al nivel manual porque no es compatible con Qt6.

Esta versión añade la siguiente funcionalidad:

  • Nueva comprobación compare-member-check: Comprueba si los operadores de una comparación no usan todas las variables miembro de una clase.

C++20 es necesario ahora para la compilación

Las comprobaciones de la adaptación a qt6-\* se han eliminado.

1.16 2025-09-03

This release fixes the following bugs:

  • unused-result-check: Fix crash when method decleration can not be resolved
  • use-chrono-in-qtimer: Fix crash when using precompiled headers
  • qt6-qhash-signature: Adapt check to use more proper logic for casts and fix crash in edgecases
  • Ensure that clang21 works properly with clazy and produces same line/letter number as before (mismatches with operator calls)
  • non-pod-global-static: Fix false positive with Q_IMPORT_PLUGIN in Qt-6.10

This release adds the following features:

  • Clazy can finally be integrated into clang-tidy - one command to rule
  • them all! All checks can be enabled using "clazy-<checkname>". For example:
  • `clazy-qstring-arg,clazy-qfileinfo-exists`, enabling all checks using
  • `clazy-*` will also enable manual checks. It is recommended to be more granular.
  • The plugin can be loaded using `-load=ClazyClangTidy.so`, for this, the plugin
  • must be in the LD_LIBRARY_PATH. Otherwise, an absolute path may be specified.
  • isempty-vs-count now provides fixits for all scenarios. Also, cases where
  • the length is compared using "== 0", "< 1", "> 0" are now reported and have fixits.
  • qt6-\* Porting checks are considered deprecated now and will be removed in the next release of clazy
  • detaching-temporary and detaching-member checks provide fixits for methods that have const coutnerparts
  • NOLINT/NOLINTNEXTLINE/NOLINTBEGIN/NOLINTEND all work in clazy now as
  • expected. Individual clazy checks can be disabled when using a "clazy-"
  • prefix. For example "NOLINTNEXTLINE(clazy-qfileinfo-exists, clazy-qstring-arg)"
1.15 2025-06-12

This release fixes the following bugs:

  • install-event-filter: Fix crash when there is no child at the given depth. BUG: 464372
  • fully-qualified-moc-types: Fix enum/enum class not being evaluated. BUG: 423780
  • Fixed crash in qstring-comparison-to-implicit-char. BUG: 502458
  • Fixed crash when fully-qualified-moc-types encounters signals with expressions like "std::bitset<int(8)>"
  • Fixed crash in qvariant-template-instantiation

This release adds the following features:

  • New checks:
  • readlock-detaching
  • Update minimum Clang/LLVM to 19
  • `clazy-standalone --version` contains git version ( output of `git describe`) if it is not a tagged commit
  • Added missing methods to checks for detaching temporary/member lists or maps
1.14 2025-04-27

Clazy warnings for the following line can be disabled, for example: clazy:exclude-next-line=check1,check2

Support for compilation against Clang 20

increase verbosity of some warning messages

checks `function-args-by-value` and `function-args-by-ref`: add function name and parameter name to warning message

checks `unused-non-trivial-variable` and `non-pod-global-static`: add variable name to warning message

This release adds the following features:

  • New checks:
  • qbytearray-conversion-to-c-style
1.13 2024-12-28

This release adds the following features:

  • New Checks:
  • used-qunused-variable

This release fixes the following bugs:

  • qstring-arg check provides a fix-it
  • Fixed unused-non-trivial-variable to not warn when [[maybe_unused]] set
  • Fixed qstring-arg for upcoming Qt 6.9
  • Fixed fully-qualified-moc-types false positive for const modifiers of generic arguments
  • Silence false positive non-pod-global-static warning for QML module initialization
  • Fix function-args-by-value false positive that would cause compile error
  • in copy constructors, assignment operators and equal checks
  • False positives for `Q_EMIT(someSignal())` are now fixed
1.12 2024-06-30

Esta versión añade las siguientes funcionalidades:

  • Nuevas comprobaciones:
  • qt-keyword-emit
  • sanitize-inline-keyword
1.11 2022-01-21

Esta versión añade las siguientes funcionalidades:

  • Nuevas comprobaciones:
  • use-arrow-operator-instead-of-data
  • use-static-qregularexpression
  • unexpected-flag-enumerator-value
  • Se ha eliminado la comprobación inefficient-qlist (corregido en Qt6).
1.10 2021-07-20

This release fixes the following bugs:

  • Requires C++17
  • Bugfixes:
  • Fixed a -Wclazy-lambda-in-connect false-positive
  • Fixed crash in copyable-polymorphic when PCH was enabled
1.9 2021-01-10

This release fixes the following bugs:

  • Fixed clazy slowdown introduced in 1.8. I can be up to 4x faster now.
  • range-loop was split in range-loop-detach and range-loop-reference
  • Fixed -Wclazy-connect-non-signal false positives
1.8 2020-11-22

Esta versión añade las siguientes funcionalidades:

  • Nuevas comprobaciones:
  • qt6-qhash-signature
  • qt6-header-fixes
  • qt6-deprecated-api-fixes
  • use-chrono-in-qtimer
  • Solución para missing-qobject-macro
1.7 2020-06-29

This release adds the following features:

  • New Checks:
  • overloaded signal
  • invalid JNI signatures
  • qstring-comparison-to-implicit-char
  • qt6-qlatin1string-to-u
  • heap-allocated-small-trivial-type: less false-positives

This release fixes the following bugs:

  • connect-non-signal: Fix case where it didn't find the pmf
  • qstring-arg warns when using QLatin1String::arg(int), as it casts to QChar

Building clazy itself is 30% faster

1.6 2019-10-12

This release adds the following features:

  • New Checks:
  • heap-allocated-small-trivial-type
  • signal-with-return-value
  • qproperty-type-mismatch, contributed by Jean-Michaël Celerier

Removed level3. Moved all level3 checks to manual level. Doesn't make sense to enable all of them.

Each one must be carefully considered.

Minimum LLVM was bumped to 5.0

Clazy no longer rewrites files directly, to avoid races when parallel invocations change the same header.

Clazy now exports a yaml file with the replacements, to be applied with clang-apply-replacements.

The same way other clang tooling does it.

The way to enable code rewrite is now: -Xclang -plugin-arg-clazy -Xclang export-fixes for clang

or -export-fixes=somefile.yaml for clazy-standalone

All other fixit arguments and fixit env variables were removed

Thanks to Christian Gagneraud for contributing the fixit yaml exporter!

This release fixes the following bugs:

  • Fixed regressions with LLVM 9.0
  • Fixit infrastructure was overhauled
1.5 2019-01-31

This release adds the following features:

  • New Checks:
  • ifndef-define-typo
  • lowercase-qml-type-name
  • qrequiredresult-candidates
  • New Fixits:
  • range-loop now supports adding missing refs or const-ref
  • range-loop now supports adding qAsConst()
  • function-args-by-ref now adding missing refs or const-ref (experimental)
  • Introduced CLAZY_FIXIT_SUFFIX env variable

Removed support for the obscure -DCLAZY_BUILD_UTILS_LIB to simplify the CMakeLists.txt

Renamed the clazy plugin from ClangLazy.so to ClazyPlugin.so

fully-qualified-moc-types now warns for slot/invokable return values too. They need to be fully qualified for QML.

This release fixes the following bug:

  • Fixed a crash (clang assert) in raw-environment-function
1.4 2018-09-23

This release adds the following features:

  • New Checks:
  • connect-by-name
  • skipped-base-method
  • qstring-varargs
  • fully-qualified-moc-types
  • qt-keywords, with fixit included
  • qhash-with-char-pointer-key
  • wrong-qevent-cast
  • static-pmf
  • raw-environment-function
  • empty-qstringliteral
  • auto-unexpected-qstringbuilder now also warns for lambdas returning QStringBuilder

performance optimizations

Added -header-filter=<regex> option to clazy-standalone. Only headers matching the regexp will

have warnings, besides the .cpp file from the translation unit, which is never filtered out.

Added -ignore-dirs=<regex> option to clazy-standalone, and its CLAZY_IGNORE_DIRS env variable equivalent.

Added CLAZY_HEADER_FILTER env variable which adds above functionality to both clazy and clazy-standalone

unused-non-trivial-variable got unused-non-trivial-variable-no-whitelist option

unused-non-trivial-variable got user-blacklist and user-whitelist support

container-inside-loop is now a manual check instead of level2

HiddenLevel was renamed to ManualLevel

connect-3arg-lambda now warns when passing a lambda to QTimer::singleShot() or QMenu::addAction()

without a context object

old-style-connect warns for QMenu::addAction() and QMessageBox::open() too now

1.3 2017-11-26

This release adds the following features:

  • New checks:
  • thread-with-slots
  • connect-3arg-lambda
  • qproperty-without-notify
  • virtual-signal
  • overridden-signal
  • qhash-namespace
  • const-signal-or-slot
  • lambda-unique-connection

missing-qobject-macro is now a level2 check, instead of level1. Because, people can omit Q_OBJECT intentionally.

Added -only-qt option, which will make clazy bailout early on non-Qt files. For this purpose, the definition of a Qt file is whenever -DQT_CORE_LIB is passed, which is usually the case in most build systems.

Added -qt-developer option, when building Qt with clazy it will honour specific guidelines for Qt, which are not many right now but the list will grow.

1.2 2017-07-08

This release adds the following features:

  • New checks:
  • install-event-filter
  • qcolor-from-literal
  • strict-iterators
  • connect-not-normalized

This release fixes the following bugs:

  • clazy-standalone executable. Allows to run clazy against a JSON compilation database instead of as a plugin. clang-tidy doesn't support loading external modules (https://github.com/llvm/llvm-project/issues/32086) so this is a good workaround.
  • qt-compat mode. Allows to disable Qt5 specific checks by passing -Xclang -plugin-arg-clazy -Xclang qt4-compat
  • returning-data-from-temporary now checks for temporary QByteArrays casting to char* when returned
  • returning-data-from-temporary now checks for assignment too, not only return statements
  • unused-non-trivial-variable now warns for unused QList, QVector and many more types
  • ASTMatchers based checks are now supported
  • clang 3.7 was dropped due to ASTMatchers source incompatibilities.
  • Use clazy v1.1 for clang >= 3.6 support
  • clazylib.so no longer gets built by default, only the plugin (ClangLazy.so) gets built. Pass -DCLAZY_BUILD_UTILS_LIB=ON to enable the utils library if you're developing tools using clazy's convenience functions, which you're probably not.
  • CLAZY_INSTALL_NO_HEADERS option was removed. Either install the utils library and headers or nothing at all. By default nothing is installed, except the plugin and man pages.
1.1 2017-02-20

Esta versión añade las siguientes funcionalidades:

  • Compatibilidad con macOS y Windows
  • Nuevas comprobaciones:
  • child-event-qobject-cast
  • ctor-missing-parent-argument
  • returning-data-from-temporary
  • qt-macros
  • base-class-event
  • connect-non-signal
  • incorrect-emit
  • tr-non-literal
  • Correcciones de fallos:
  • clang 4.0
  • Qt 5.9
  • Notas:
  • Mejora el rendimiento un 60 %
  • Se han corregido muchos falsos positivos
1.0 2016-09-12
0.0.1 2015-06-10
Primera versión