CLAZY(1)
๐ CLAZY(1) โ the KDAB girlie's guide to clazy
okay so bestie, you know how I keep telling you static analysis is not a vibe-killer but actually the most self-care thing you can do for your C++? This is the page for clazy, manual section 1, and yes it's the glow-up your Qt5 codebase has been begging for. Grab a strawberry drink ๐, let's go.
โจ NAME โจ
clazy โ a static source code analyzer for Qt5-based C++.
Like, it reads your code and tells you about your choices. Lovingly. Mostly. ๐
๐ธ SYNOPSIS ๐ธ
clazy [option] [clang++-options]
That's it. That's the whole mood. One command, options, then all your clang++ stuff. ๐
๐ฆ DESCRIPTION ๐ฆ
So clazy scans your C++/Qt source code looking for issues related to good coding practice with Qt5. Scans. Looks. Judges gently. And here's the fun part: in typical use, during code compilation with clazy, you'll see any such warnings printed to the output, normally, just like you'd find any compiler warnings. So it's not some whole separate flow โ it just shows up in your build output like "hey queen, this line is giving questionable". ๐ญ
And clazy has the ability to "fix" the offending code in some cases. Yes, actual automatic fixing. icon behavior. See the CLAZY_FIXIT environment variable description below for more info. ๐
โจ OPTIONS โจ
Let's do the roundup, bestie:
--helpโ Prints the help message and then exits. Classic. ๐ซถ--versionโ Prints version information and exits. Identity check. ๐--listโ Prints a list of all available checkers, arranged by level. This is the one you run first, no cap.--explainโ Prints explanations for all checkers. All of them. The full syllabus. ๐--explain<regexp>โ Prints explanations for the checkers matching the specified regular expression. So you can be picky, and honestly? slay.
Heads up: any of the options above will print the requested information and then exit. Like, it's a one-and-done, it's not sticking around to compile anything.
--qtdeveloperโ For Qt developers only. Qt developers ONLY. This option is special for runningclazyon Qt itself, and it will result in fewer false positives being reported in Qt code.
It's a convenience option which is identical to directly passing:
"-Xclang -plugin-arg-clazy -Xclang qt-developer"
So like, you could type all that, but why would you. ๐
All other options are passed directly to clang++ and handled from there. Every single one. Not our business, we hand it off. ๏ฟฝ๏ฟฝ
See the clang manual for a list of the very large set of options available โ and it is very large, like genuinely huge โ but in normal operation you "compile" your code with clazy just as you would with clang. Same energy, better feedback.
๐ EXAMPLES ๐
Print a list of all available checkers, arranged by check level
% clazy --list
List of available clazy checkers:
Checks from level0. Very stable checks, 100% safe, no false-positives:
connect-non-signal
container-anti-pattern
lambda-in-connect
mutable-container-key
qdatetime-utc
qenums
qfileinfo-exists
....
100% safe, no false-positives โ the level0 girlies are the trustworthy ones, that's the whole point. ๐
Compile your CMake project with clazy default checkers
% cmake -DCMAKE_CXX_COMPILER=clazy <other_cmake_options>
then make as normal
"then make as normal" โ like literally just carry on, that's the entire trick. ๐ง
Compile your CMake project with level2 checks only (non-Windows)
% export CLAZY_CHECKS="level2"
% cmake -DCMAKE_CXX_COMPILER=clazy <other_cmake_options>
then make as normal
Note the (non-Windows) bestie. That's not me being cute, that's the actual scope. ๐
Compile your qmake project with clazy default checkers
% qmake -spec linux-clang QMAKE_CXX=clazy <other_qmake_options>
then make as normal
qmake girlies, we see you, we love you, same deal. ๐ธ
๐ฅ IN-CODE DIRECTIVES ๐ฅ
okay this is the part where you get to talk back to the tool. clazy supports the following list of in-code directives:
clazy:skipโ Exempt an entire file from all checks. Noclazytests will run on the file. Whole file, off the table, not today. ๐clazy:excludeall=<name1[,name2,...,nameN]>โ Exempt the entire file from the specified checks. The clazy checksname1, etc. will not be run on this file. So it's skip, but picky.clazy:exclude=<name1[,name2,...,nameN]>โ Exclude individual lines from specific checks. The clazy checks testsname1, etc. will not be run on the line where this directive is found. Just that one line. Micro-exclusion. iconic.clazy:exclude-next-line=<name1[,name2,...,nameN]>โ Excludes the given clazy checks from the next line. Future-line exemption, she's forward-thinking. ๐ฎ
The important bit: Don't include theclazy-prefix. For example, to disable theqstring-allocationscheck, you would write:
// clazy:exclude=qstring-allocations
and not:
// clazy:exclude=clazy-qstring-allocations
Also note that these directives must be C++ style comments; C style comments are ignored. So // yes, /* */ no โ she will simply not read it, fr fr. ๐
๐ ENVIRONMENT ๐
CLAZY_CHECKSโ a comma-separated list of checkers or check-sets to run. By default, all checkers from the"level0"and"level1"check-sets will run. That's the default. No config needed, she's already working. โจ
Examples:
- Enables the 2 checkers
"unneeded-cast"and"virtual-call-ctor"only:
% export CLAZY_CHECKS="unneeded-cast,virtual-call-ctor"
- Enables all checks from the
"level0"check-set, except for"qenums":
% export CLAZY_CHECKS="level0,no-qenums"
- Enables all checks from the
"level0"check-set along with the"detaching-temporary"checker:
% export CLAZY_CHECKS="level0,detaching-temporary"
see how you can mix a whole level with one specific checker? that's the good stuff.
CLAZY_FIXITโ some checkers are able to automatically re-write your source code whenever it encounters code it can"fix". Enable this"fixit"feature by setting this variable to the name of the checker with a"fixit"capability.
Examples:
- Fix qlatin1string allocations:
% export CLAZY_FIXIT="fix-qlatin1string-allocations"
- Fix old-style (simple cases) connect statements:
% export CLAZY_FIXIT=fix-old-style-connect
More documentation is provided when running clazy with the --explain command line option. ๐
Also note that only 1 fixit checker can be run at a time. ONE. Not two, not "just a couple", one. Choose wisely bestie. ๐
CLAZY_EXTRA_OPTIONSโ some checkers can adapt their behavior depending on the value of this environment variable. More documentation is provided when runningclazywith the--explaincommand line option. She's flexible, but she's not gonna explain herself here. ๐CLAZY_NO_WERRORโ if this is variable is set,clazywill not treat warnings as errors, even if the-Werrorcompiler option is specified. This is useful if you want to use-Werroronly for the regulargcc/clangwarnings but not forclazywarnings. So you get to be strict with everyone else and gentle with yourself. growth.CLAZY_CHECKS_AS_ERRORSโ comma-separated list of checks that will be promoted to compiler errors. Note that this does not enable the checks specified here. Like, it promotes them, it does not summon them. Two different things. ๐CLAZY_IGNORE_DIRSโ A regular expression for paths to exclude from processing. For example:
% export CLAZY_IGNORE_DIRS=".*my_qt_folder.*"
Bye bye my_qt_folder, we simply do not see her. ๐ฆ
๐ COPYRIGHT AND LICENSE ๐
Copyright (C) 2015-2017 Klaralvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library. If not, see <http://www.gnu.org/licenses/>.
(lowercase gnu dot org, no www, copy it exactly bestie โ licensing is not a place to freestyle ๐ซถ)
๐ง SEE ALSO ๐ง
clang(1)
https://www.kdab.com/use-static-analysis-improve-performance
like, read the clang manual, and then read that KDAB article, that's the assignment. ๐
๐ AUTHORS ๐
The whole squad, respectfully:
Sergio Martins <sergio.martins@kdab.com>
Laurent Montel <laurent.montel@kdab.com>
Allen Winter <allen.winter@kdab.com>
Albert Astals Cid <aacid@kde.org>
Aurรฉlien Gรขteau <agateau@kde.org>
Kevin Funk <kevin.funk@kdab.com>
Hannah von Reth <hannah.vonreth@kdab.com>
Volker Krause <volker.krause@kdab.com>
Christian Ehrlicher <Ch.Ehrlicher@gmx.de>
Mathias Hasselmann <mathias.hasselmann@kdab.com>
and that's the page!! ๐ go forth, compile with clazy, let her fix your connect statements, and remember: level0 will never lie to you.
cute little sign-off for the footer energy: this is version 1.17.1, dated 2026-04-08, section CLAZY(1) โ mwah, bye bestie ๐๐
๐ฆ where this page comes from
- alpine 3.24: clazy-doc 1.17.1-r1 ยท LGPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms