Warning, /sdk/clazy/README.md is written in an unsupported language. File is not indexed.
0001 -*WARNING:* master is the development branch. Please use the v1.11 branch. 0002 0003 clazy v1.12 0004 =========== 0005 0006 clazy is a compiler plugin which allows clang to understand Qt semantics. You get more than 50 Qt related compiler warnings, ranging from unneeded memory allocations to misusage of API, including fix-its for automatic refactoring. 0007 0008 Table of contents 0009 ================= 0010 0011 * [Source Code](#source-code) 0012 * [Build Instructions](#build-instructions) 0013 * [Linux](#linux) 0014 * [Install dependencies](#install-dependencies) 0015 * [Build and install clang](#build-and-install-clang) 0016 * [Build clazy](#build-clazy) 0017 * [Windows](#windows) 0018 * [Build and install clang](#build-and-install-clang-1) 0019 * [Build clazy](#build-clazy-1) 0020 * [macOS with MacPorts](#macos-with-macports) 0021 * [Install clang](#install-clang) 0022 * [Build clazy](#build-clazy-2) 0023 * [macOS with Homebrew](#macos-with-homebrew) 0024 * [Install clang](#install-clang-1) 0025 * [Build clazy](#build-clazy-3) 0026 * [Setting up your project to build with clazy](#setting-up-your-project-to-build-with-clazy) 0027 * [List of checks](#list-of-checks) 0028 * [Selecting which checks to enable](#selecting-which-checks-to-enable) 0029 * [Example via env variable](#example-via-env-variable) 0030 * [Example via compiler argument](#example-via-compiler-argument) 0031 * [clazy-standalone and JSON database support](#clazy-standalone-and-json-database-support) 0032 * [Enabling Fixits](#enabling-fixits) 0033 * [Troubleshooting](#troubleshooting) 0034 * [Qt4 compatibility mode](#qt4-compatibility-mode) 0035 * [Reducing warning noise](#reducing-warning-noise) 0036 * [Reporting bugs and wishes](#reporting-bugs-and-wishes) 0037 * [Authors](#authors) 0038 * [Contributing patches](#contributing-patches) 0039 0040 # Source Code 0041 0042 You can get clazy from: 0043 0044 - <https://github.com/KDE/clazy> 0045 - <https://invent.kde.org/sdk/clazy> 0046 0047 0048 # Supported platforms 0049 0050 Clazy has been tested on Linux, macOS and Windows/MSVC. 0051 Other platforms are not supported but we'll gladly accept patches. 0052 0053 0054 # Build Instructions 0055 ## Linux 0056 0057 ### Install dependencies 0058 - OpenSUSE tumbleweed: `zypper install cmake git-core llvm llvm-devel llvm-clang llvm-clang-devel` 0059 - Ubuntu: `apt install g++ cmake clang llvm-dev git-core libclang-dev` 0060 - Archlinux: `pacman -S make llvm clang python2 cmake git gcc` 0061 - Fedora: be sure to *remove* the llvm-static package and only install the one with dynamic libraries 0062 - Other distros: Check llvm/clang build docs. 0063 0064 ### Build and install clang 0065 clang and LLVM >= 8.0 are required. 0066 0067 If your distro provides clang then you can skip this step. 0068 0069 0070 ``` 0071 $ git clone https://github.com/llvm-mirror/llvm.git <some_directory> 0072 $ cd <some_directory>/tools/ && git clone https://github.com/llvm-mirror/clang.git 0073 $ cd <some_directory>/projects && git clone https://github.com/llvm-mirror/compiler-rt.git 0074 $ mkdir <some_directory>/build && cd <some_directory>/build 0075 $ cmake -DCMAKE_INSTALL_PREFIX=<prefix> -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_BUILD_TYPE=Release -G Ninja .. 0076 $ cmake --build . 0077 $ cmake --build . --target install 0078 ``` 0079 0080 ### Build clazy 0081 ``` 0082 $ cd clazy/ 0083 $ cmake -DCMAKE_INSTALL_PREFIX=<prefix> -DCMAKE_BUILD_TYPE=Release -G Ninja 0084 $ cmake --build . 0085 $ cmake --build . --target install 0086 ``` 0087 0088 See troubleshooting section if you have problems. 0089 0090 ## Windows 0091 0092 ### Build and install clang 0093 These instructions assume your terminal is suitable for development. 0094 Ninja (or equivalent), git, cmake, and cl (msvc2019) should be in your PATH. 0095 0096 clang and LLVM >= 9.0 are required. 0097 0098 Be sure to pass -DLLVM_EXPORT_SYMBOLS_FOR_PLUGINS=ON to CMake when building LLVM, otherwise clazy won't work. 0099 0100 ``` 0101 > git clone https://github.com/llvm/llvm-project.git -b llvmorg-11.0.0 <some_directory> 0102 > mkdir build # Important that this is outside of the source directory 0103 > cd build 0104 > cmake -DCMAKE_INSTALL_PREFIX=c:\my_install_folder\llvm\ -DLLVM_EXPORT_SYMBOLS_FOR_PLUGINS=ON -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" -DCMAKE_BUILD_TYPE=Release -G "Ninja" ../<some_directory>/llvm 0105 > cmake --build . 0106 > cmake --build . --target install 0107 > Add c:\my_install_folder\llvm\bin\ to PATH 0108 ``` 0109 0110 Also be sure to copy the generated `C:\path\to\llvm-build\lib\clang.lib` to your installation folder somewhere. It contains the exported symbols of clang.exe, which the plugins need. 0111 Unfortunately LLVM doesn't install it. You can put it anywhere, just save it so you can delete the build directory. 0112 0113 ### Build clazy 0114 0115 Be sure to point CLANG_LIBRARY_IMPORT to clang.lib. It's probably inside your LLVM build dir since it doesn't get installed. 0116 0117 ``` 0118 > cd clazy\ 0119 > cmake -DCMAKE_INSTALL_PREFIX=c:\my_install_folder\llvm\ -DCLANG_LIBRARY_IMPORT=C:\path\to\llvm-build\lib\clang.lib -DCMAKE_BUILD_TYPE=Release -G "Ninja" 0120 > cmake --build . 0121 > cmake --build . --target install 0122 ``` 0123 0124 ## macOS with MacPorts 0125 0126 ### Install clang 0127 ``` 0128 $ sudo port install llvm-11 clang-11 cmake ninja coreutils 0129 $ sudo ln -sf /opt/local/bin/llvm-config-mp-11 /opt/local/bin/llvm-config 0130 $ sudo port select --set clang mp-clang-11 0131 ``` 0132 0133 ### Build clazy 0134 ``` 0135 $ export CXX=clang++ 0136 $ cmake -G Ninja 0137 $ cmake --build . 0138 $ cmake --build . --target install 0139 ``` 0140 0141 ## macOS with Homebrew 0142 0143 The recommended way is to build clazy yourself, but alternatively you can try user recipes, such as: 0144 0145 ``` 0146 $ brew install kde-mac/kde/clazy 0147 ``` 0148 0149 for stable branch, or for master: 0150 0151 ``` 0152 $ brew install kde-mac/kde/clazy --HEAD 0153 ``` 0154 0155 As these are not verified or tested by the clazy developers please don't report bugs to us. 0156 0157 For building yourself, read on. You'll have to install clang and build clazy from source. 0158 0159 ### Install clang 0160 0161 ``` 0162 $ brew install --with-clang llvm 0163 ``` 0164 0165 ### Build clazy 0166 ``` 0167 $ export CXX=clang++ 0168 $ export LLVM_ROOT=/usr/local/opt/llvm 0169 $ cmake -G Ninja 0170 $ cmake --build . 0171 $ cmake --build . --target install 0172 ``` 0173 0174 # Setting up your project to build with clazy 0175 0176 Note: Wherever `clazy` is mentioned, replace with `clazy-cl.bat` if you're on Windows, or replace with `Clazy-x86_64.AppImage` if you're using AppImage. 0177 Note: If you prefer running clazy over a JSON compilation database instead of using it as a plugin, jump to [clazy-standalone](#clazy-standalone-and-json-database-support). 0178 0179 You should now have the clazy command available to you, in `<prefix>/bin/`. 0180 Compile your programs with it instead of clang++/g++. 0181 0182 Note that this command is just a convenience wrapper which calls: 0183 `clang++ -Xclang -load -Xclang ClazyPlugin.so -Xclang -add-plugin -Xclang clazy` 0184 0185 If you have multiple versions of clang installed (say clang++-10 and clang++-11) 0186 you can choose which one to use by setting the CLANGXX environment variable, like so: 0187 `export CLANGXX=clang++-11; clazy` 0188 0189 To build a CMake project use: 0190 `cmake . -DCMAKE_CXX_COMPILER=clazy` 0191 and rebuild. 0192 0193 To make it the compiler for qmake projects, just run qmake like: 0194 `qmake -spec linux-clang QMAKE_CXX="clazy"` 0195 0196 On Windows with MSVC it's simply: `qmake QMAKE_CXX="clazy-cl.bat"` 0197 0198 Alternatively, if you want to use clang directly, without the wrapper: 0199 `qmake -spec linux-clang QMAKE_CXXFLAGS="-Xclang -load -Xclang ClazyPlugin.so -Xclang -add-plugin -Xclang clazy"` 0200 0201 On Windows it's similar, just inspect the contents of `clazy-cl.bat`. 0202 0203 0204 It's recommended that you disable pre-compiled headers and don't use ccache. 0205 0206 You're all set, clazy will now run some checks on your project, but not all of them. 0207 Read on if you want to enable/disable which checks are run. 0208 0209 # List of checks 0210 0211 There are many checks and they are divided in levels: 0212 - level0: Very stable checks, 99.99% safe, mostly no false-positives, very desirable 0213 - level1: The default level. Very similar to level 0, slightly more false-positives but very few. 0214 - level2: Also very few false-positives, but contains noisy checks which not everyone agree should be default. 0215 - manual: Checks here need to be enabled explicitly, as they don't belong to any level. They can be very stable or very unstable. 0216 0217 clazy runs all checks from level1 by default. 0218 0219 - Checks from Manual Level: 0220 - [assert-with-side-effects](docs/checks/README-assert-with-side-effects.md) 0221 - [container-inside-loop](docs/checks/README-container-inside-loop.md) 0222 - [detaching-member](docs/checks/README-detaching-member.md) 0223 - [heap-allocated-small-trivial-type](docs/checks/README-heap-allocated-small-trivial-type.md) 0224 - [ifndef-define-typo](docs/checks/README-ifndef-define-typo.md) 0225 - [isempty-vs-count](docs/checks/README-isempty-vs-count.md) 0226 - [jni-signatures](docs/checks/README-jni-signatures.md) 0227 - [qhash-with-char-pointer-key](docs/checks/README-qhash-with-char-pointer-key.md) 0228 - [qproperty-type-mismatch](docs/checks/README-qproperty-type-mismatch.md) 0229 - [qrequiredresult-candidates](docs/checks/README-qrequiredresult-candidates.md) 0230 - [qstring-varargs](docs/checks/README-qstring-varargs.md) 0231 - [qt-keyword-emit](docs/checks/README-qt-keyword-emit.md) (fix-qt-keyword-emit) 0232 - [qt-keywords](docs/checks/README-qt-keywords.md) (fix-qt-keywords) 0233 - [qt4-qstring-from-array](docs/checks/README-qt4-qstring-from-array.md) (fix-qt4-qstring-from-array) 0234 - [qt6-deprecated-api-fixes](docs/checks/README-qt6-deprecated-api-fixes.md) (fix-qt6-deprecated-api-fixes) 0235 - [qt6-fwd-fixes](docs/checks/README-qt6-fwd-fixes.md) (fix-qt6-fwd-fixes) 0236 - [qt6-header-fixes](docs/checks/README-qt6-header-fixes.md) (fix-qt6-header-fixes) 0237 - [qt6-qhash-signature](docs/checks/README-qt6-qhash-signature.md) (fix-qt6-qhash-signature) 0238 - [qt6-qlatin1stringchar-to-u](docs/checks/README-qt6-qlatin1stringchar-to-u.md) (fix-qt6-qlatin1stringchar-to-u) 0239 - [qvariant-template-instantiation](docs/checks/README-qvariant-template-instantiation.md) 0240 - [raw-environment-function](docs/checks/README-raw-environment-function.md) 0241 - [reserve-candidates](docs/checks/README-reserve-candidates.md) 0242 - [sanitize-inline-keyword](docs/checks/README-sanitize-inline-keyword.md) (fix-sanitize-inline-keyword) 0243 - [signal-with-return-value](docs/checks/README-signal-with-return-value.md) 0244 - [thread-with-slots](docs/checks/README-thread-with-slots.md) 0245 - [tr-non-literal](docs/checks/README-tr-non-literal.md) 0246 - [unexpected-flag-enumerator-value](docs/checks/README-unexpected-flag-enumerator-value.md) 0247 - [unneeded-cast](docs/checks/README-unneeded-cast.md) 0248 - [unused-result-check](docs/checks/README-unused-result-check.md) 0249 - [use-arrow-operator-instead-of-data](docs/checks/README-use-arrow-operator-instead-of-data.md) 0250 - [use-chrono-in-qtimer](docs/checks/README-use-chrono-in-qtimer.md) 0251 0252 - Checks from Level 0: 0253 - [connect-by-name](docs/checks/README-connect-by-name.md) 0254 - [connect-non-signal](docs/checks/README-connect-non-signal.md) 0255 - [connect-not-normalized](docs/checks/README-connect-not-normalized.md) 0256 - [container-anti-pattern](docs/checks/README-container-anti-pattern.md) 0257 - [empty-qstringliteral](docs/checks/README-empty-qstringliteral.md) 0258 - [fully-qualified-moc-types](docs/checks/README-fully-qualified-moc-types.md) (fix-fully-qualified-moc-types) 0259 - [lambda-in-connect](docs/checks/README-lambda-in-connect.md) 0260 - [lambda-unique-connection](docs/checks/README-lambda-unique-connection.md) 0261 - [lowercase-qml-type-name](docs/checks/README-lowercase-qml-type-name.md) 0262 - [mutable-container-key](docs/checks/README-mutable-container-key.md) 0263 - [no-module-include](docs/checks/README-no-module-include.md) 0264 - [overloaded-signal](docs/checks/README-overloaded-signal.md) 0265 - [qcolor-from-literal](docs/checks/README-qcolor-from-literal.md) (fix-qcolor-from-literal) 0266 - [qdatetime-utc](docs/checks/README-qdatetime-utc.md) (fix-qdatetime-utc) 0267 - [qenums](docs/checks/README-qenums.md) 0268 - [qfileinfo-exists](docs/checks/README-qfileinfo-exists.md) (fix-qfileinfo-exists) 0269 - [qgetenv](docs/checks/README-qgetenv.md) (fix-qgetenv) 0270 - [qmap-with-pointer-key](docs/checks/README-qmap-with-pointer-key.md) 0271 - [qstring-arg](docs/checks/README-qstring-arg.md) 0272 - [qstring-comparison-to-implicit-char](docs/checks/README-qstring-comparison-to-implicit-char.md) 0273 - [qstring-insensitive-allocation](docs/checks/README-qstring-insensitive-allocation.md) 0274 - [qstring-ref](docs/checks/README-qstring-ref.md) (fix-missing-qstringref) 0275 - [qt-macros](docs/checks/README-qt-macros.md) 0276 - [strict-iterators](docs/checks/README-strict-iterators.md) 0277 - [temporary-iterator](docs/checks/README-temporary-iterator.md) 0278 - [unused-non-trivial-variable](docs/checks/README-unused-non-trivial-variable.md) 0279 - [use-static-qregularexpression](docs/checks/README-use-static-qregularexpression.md) 0280 - [writing-to-temporary](docs/checks/README-writing-to-temporary.md) 0281 - [wrong-qevent-cast](docs/checks/README-wrong-qevent-cast.md) 0282 - [wrong-qglobalstatic](docs/checks/README-wrong-qglobalstatic.md) 0283 0284 - Checks from Level 1: 0285 - [auto-unexpected-qstringbuilder](docs/checks/README-auto-unexpected-qstringbuilder.md) (fix-auto-unexpected-qstringbuilder) 0286 - [child-event-qobject-cast](docs/checks/README-child-event-qobject-cast.md) 0287 - [connect-3arg-lambda](docs/checks/README-connect-3arg-lambda.md) 0288 - [const-signal-or-slot](docs/checks/README-const-signal-or-slot.md) 0289 - [detaching-temporary](docs/checks/README-detaching-temporary.md) 0290 - [foreach](docs/checks/README-foreach.md) 0291 - [incorrect-emit](docs/checks/README-incorrect-emit.md) 0292 - [install-event-filter](docs/checks/README-install-event-filter.md) 0293 - [non-pod-global-static](docs/checks/README-non-pod-global-static.md) 0294 - [overridden-signal](docs/checks/README-overridden-signal.md) 0295 - [post-event](docs/checks/README-post-event.md) 0296 - [qdeleteall](docs/checks/README-qdeleteall.md) 0297 - [qhash-namespace](docs/checks/README-qhash-namespace.md) 0298 - [qlatin1string-non-ascii](docs/checks/README-qlatin1string-non-ascii.md) 0299 - [qproperty-without-notify](docs/checks/README-qproperty-without-notify.md) 0300 - [qstring-left](docs/checks/README-qstring-left.md) 0301 - [range-loop-detach](docs/checks/README-range-loop-detach.md) (fix-range-loop-add-qasconst) 0302 - [range-loop-reference](docs/checks/README-range-loop-reference.md) (fix-range-loop-add-ref) 0303 - [returning-data-from-temporary](docs/checks/README-returning-data-from-temporary.md) 0304 - [rule-of-two-soft](docs/checks/README-rule-of-two-soft.md) 0305 - [skipped-base-method](docs/checks/README-skipped-base-method.md) 0306 - [virtual-signal](docs/checks/README-virtual-signal.md) 0307 0308 - Checks from Level 2: 0309 - [base-class-event](docs/checks/README-base-class-event.md) 0310 - [copyable-polymorphic](docs/checks/README-copyable-polymorphic.md) 0311 - [ctor-missing-parent-argument](docs/checks/README-ctor-missing-parent-argument.md) 0312 - [function-args-by-ref](docs/checks/README-function-args-by-ref.md) (fix-function-args-by-ref) 0313 - [function-args-by-value](docs/checks/README-function-args-by-value.md) 0314 - [global-const-char-pointer](docs/checks/README-global-const-char-pointer.md) 0315 - [implicit-casts](docs/checks/README-implicit-casts.md) 0316 - [missing-qobject-macro](docs/checks/README-missing-qobject-macro.md) (fix-missing-qobject-macro) 0317 - [missing-typeinfo](docs/checks/README-missing-typeinfo.md) 0318 - [old-style-connect](docs/checks/README-old-style-connect.md) (fix-old-style-connect) 0319 - [qstring-allocations](docs/checks/README-qstring-allocations.md) (fix-qlatin1string-allocations,fix-fromLatin1_fromUtf8-allocations,fix-fromCharPtrAllocations) 0320 - [returning-void-expression](docs/checks/README-returning-void-expression.md) 0321 - [rule-of-three](docs/checks/README-rule-of-three.md) 0322 - [static-pmf](docs/checks/README-static-pmf.md) 0323 - [virtual-call-ctor](docs/checks/README-virtual-call-ctor.md) 0324 0325 # Selecting which checks to enable 0326 0327 You may want to choose which checks to enable before starting to compile. 0328 If you don't specify anything then all checks from level0 and level1 will run. 0329 To specify a list of checks to run, or to choose a level, you can use the `CLAZY_CHECKS` env variable or pass arguments to the compiler. 0330 You can disable checks by prefixing with `no-`, in case you don't want all checks from a given level. 0331 0332 ## Example via env variable 0333 ``` 0334 export CLAZY_CHECKS="unneeded-cast,qmap-with-pointer-key,virtual-call-ctor" # Enables only these 3 checks 0335 export CLAZY_CHECKS="level0,no-qenums" # Enables all checks from level0, except for qenums 0336 export CLAZY_CHECKS="level0,detaching-temporary" # Enables all from level0 and also detaching-temporary 0337 ``` 0338 ## Example via compiler argument 0339 `clazy -Xclang -plugin-arg-clazy -Xclang level0,detaching-temporary` 0340 Don't forget to re-run cmake/qmake/etc if you altered the c++ flags to specify flags. 0341 0342 # clazy-standalone and JSON database support 0343 0344 The `clazy-standalone` binary allows you to run clazy over a compilation database JSON file, in the same 0345 way you would use `clang-tidy` or other clang tooling. This way you don't need to build your application, 0346 only the static analysis is performed. 0347 0348 Note: If you're using the AppImage, use `Clazy-x86_64.AppImage --standalone` instead of `clazy-standalone`. 0349 0350 `clazy-standalone` supports the same env variables as the clazy plugin. You can also specify a list of checks via 0351 the `-checks` argument. 0352 0353 0354 Running on one cpp file: 0355 `clazy-standalone -checks=install-event-filter,qmap-with-pointer-key,level0 -p compile_commands.json my.file.cpp` 0356 0357 Running on all cpp files: 0358 `find . -name "*cpp" | xargs clazy-standalone -checks=level2 -p default/compile_commands.json` 0359 0360 See https://clang.llvm.org/docs/JSONCompilationDatabase.html for how to generate the compile_commands.json file. Basically it's generated 0361 by passing `-DCMAKE_EXPORT_COMPILE_COMMANDS` to CMake, or using [Bear](https://github.com/rizsotto/Bear) to intercept compiler commands, or, if you're using `qbs`: 0362 0363 `qbs generate --generator clangdb` 0364 0365 **Note:** Be sure the clazy-standalone binary is located in the same folder as the clang binary, otherwise it will have trouble 0366 finding builtin headers, like stddef.h. Alternatively, you can symlink to the folder containing the builtin headers: 0367 0368 (Assuming clazy was built with `-DCMAKE_INSTALL_PREFIX=/myprefix/`) 0369 0370 ``` 0371 $ touch foo.c && clang++ '-###' -c foo.c 2>&1 | tr ' ' '\n' | grep -A1 resource # Make sure this clang here is not Apple clang. Use for example clang++-mp-8.0 if on macOS and haven't run `port select` yet. 0372 "-resource-dir" 0373 "/opt/local/libexec/llvm-8.0/lib/clang/8.0.1" # The interesting part is /opt/local/libexec/llvm-8.0 0374 $ ln -sf /opt/local/libexec/llvm-8.0/lib/clang/ /myprefix/lib/clang 0375 $ mkdir /myprefix/include/ 0376 $ ln -sf /opt/local/libexec/llvm-8.0/include/c++/ /myprefix/include/c++ # Required on macOS 0377 ``` 0378 0379 If that doesn't work, run `clang -v` and check what's the InstalledDir. Move clazy-standalone to that folder. 0380 0381 `clang-tidy` support will be added after <https://github.com/llvm/llvm-project/issues/32086> is fixed. 0382 0383 # Enabling Fixits 0384 0385 Some checks support fixits, in which clazy will help re-write your source files whenever it can fix something. 0386 Simply pass `-Xclang -plugin-arg-clazy -Xclang export-fixes` to clang, or `-export-fixes=somefile.yaml` for `clazy-standalone`. 0387 Alternatively, set the `CLAZY_EXPORT_FIXES` env variable (works only with the plugin, not with standalone). 0388 Then run `clang-apply-replacements <folder_with_yaml_files>`, which will modify your code. 0389 0390 When using fixits, prefer to run only a single check each time, so they don't conflict 0391 with each other modifying the same source lines. 0392 0393 **WARNING**: Backup your code and make sure all changes done by clazy are correct. 0394 0395 # Troubleshooting 0396 0397 - clang: symbol lookup error: `/usr/lib/x86_64-linux-gnu/ClazyPlugin.so: undefined symbol: _ZNK5clang15DeclarationName11getAsStringEv`. 0398 This is due to mixing ABIs. Your clang/llvm was compiled with the [new gcc c++ ABI][1] but you compiled the clazy plugin with clang (which uses [the old ABI][2]). 0399 0400 The solution is to build the clazy plugin with gcc or use a distro which hasn't migrated to gcc5 ABI yet, such as archlinux. 0401 0402 [1]: https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html 0403 [2]: https://llvm.org/bugs/show_bug.cgi?id=23529 0404 0405 - [Fedora] cmake can't find LLVM ? 0406 Try building llvm/clang yourself 0407 (There are reports that /usr/share/llvm/cmake/LLVM-Config.cmake is buggy). 0408 0409 - [Fedora] CommandLine Error: `Option 'opt-bisect-limit' registered more than once!` 0410 Remove the llvm-static package and use the dynamically linked libraries instead. 0411 Alternatively, if you want to use llvm-static, see next item. 0412 0413 - CommandLine Error: `Option 'foo' registered more than once!` 0414 Means you're building against a static version of LLVM (*.a files instead of *.so). 0415 Try passing to cmake -DLINK_CLAZY_TO_LLVM=OFF when building clazy, this was tested 0416 successfully against a static LLVM 7.0, and might work with other versions. 0417 0418 - Some checks are mysteriously not producing warnings or not applying fixits ? 0419 Check if you have ccache interfering and turn it off. 0420 0421 - fatal error: 'stddef.h' file not found, while using `clazy-standalone` 0422 Be sure the clazy-standalone binary is located in the same folder as the clang binary. 0423 0424 - Be sure to disable pch. 0425 0426 - macOS: Be sure you're not using Apple Clang 0427 0428 - macOS: System Integrity Protection blocks the use of DYLD_LIBRARY_PATH. With SIP enabled you need to pass the full path 0429 to ClazyPlugin.dylib, otherwise you'll get `image not found` error. 0430 0431 - Windows: fatal error LNK1112: module machine type ‘X86’ conflicts with target machine type ‘x64’ 0432 If you're building in 32-bit, open clazy-cl.bat and insert a -m32 argument. 0433 Should read: %~dp0\clang\clang.exe –driver-mode=cl -m32 (...) 0434 0435 # Qt4 compatibility mode 0436 0437 When running on codebases that must still compile with Qt4, you can pass `--qt4compat` 0438 (a convenience option equivalent to passing `-Xclang -plugin-arg-clazy -Xclang qt4-compat`) 0439 to disable checks that only make sense with Qt5. 0440 0441 For example, to build a CMake project with Qt4 compatibility use: 0442 `CXX="clazy --qt4compat"; cmake .` 0443 and rebuild. 0444 0445 # Reducing warning noise 0446 0447 If you think you found a false-positive, file a bug report. But do make sure to test first without icecc/distcc enabled. 0448 0449 If you want to suppress warnings from headers of Qt or 3rd party code, include them with `-isystem` instead of `-I` (gcc/clang only). 0450 For MSVC use `/external`, which is available since VS 15.6. 0451 0452 Alternatively you can set the CLAZY_HEADER_FILTER env variable to a regexp matching the path where you want warnings, 0453 for example `CLAZY_HEADER_FILTER=.*myapplication.*`. 0454 0455 You can also exclude paths using a regexp by setting CLAZY_IGNORE_DIRS, for example `CLAZY_IGNORE_DIRS=.*my_qt_folder.*`. 0456 0457 You can also suppress individual warnings by file or by line by inserting comments: 0458 0459 - To disable clazy in a specific source file, insert this comment, anywhere in the file: 0460 `// clazy:skip` 0461 0462 - To disable specific checks in a source file, insert a comment such as 0463 `// clazy:excludeall=check1,check2` 0464 0465 - To disable specific checks in specific source lines, insert a comment in the same line as the warning: 0466 `(...) // clazy:exclude=check1,check2` 0467 0468 Don't include the `clazy-` prefix. If, for example, you want to disable qstring-allocations you would write: 0469 `// clazy:exclude=qstring-allocations` not `clazy-qstring-allocations`. 0470 0471 # Reporting bugs and wishes 0472 0473 - bug tracker: <https://bugs.kde.org/enter_bug.cgi?product=clazy> 0474 - IRC: #kde-clazy (irc.libera.chat) 0475 - E-mail: <smartins at kde.org> 0476 0477 When reporting a bug *please* include a minimal compilable testcase. No matter 0478 how simple it is, it saves me time from deciphering a bug report. Time spent 0479 doing triaging is time not spent writing fixes. 0480 0481 A minimal testcase is also something I can copy to the test suite. 0482 0483 Make sure you can reproduce with clazy (outside of QtCreator), otherwise it can be a QtCreator bug instead, 0484 which you can report at <https://bugreports.qt.io/>. 0485 0486 0487 # Authors 0488 0489 - Sérgio Martins 0490 0491 with contributions from: 0492 0493 - Allen Winter 0494 - Kevin Funk 0495 - Mathias Hasselmann 0496 - Laurent Montel 0497 - Albert Astals Cid 0498 - Aurélien Gâteau 0499 - Hannah von Reth 0500 - Volker Krause 0501 - Christian Ehrlicher 0502 - Christian Gagneraud 0503 - Nikolai Kosjar 0504 - Jesper K. Pedersen 0505 - Lucie Gerard 0506 - Christian Schärf 0507 - Waqar Ahmed 0508 - Alexander Lohnau 0509 0510 qt6-* porting checks written by Lucie Gerard <lucie.gerard@qt.io> 0511 0512 and thanks to: 0513 0514 - Klarälvdalens Datakonsult AB (<http://www.kdab.com>), for letting me work on clazy as a research project 0515 0516 0517 # Contributing patches 0518 0519 New features go to master and bug fixes go to the 1.11 branch. 0520 The preferred way to contributing is by using KDE's GitLab instance, 0521 see <https://community.kde.org/Infrastructure/GitLab>. 0522 0523 If you rather just create a pull request in https://github.com/KDE/clazy for a drive-by change, it's also fine, but beware that 0524 the maintainer might forget to check on github and the KDE bot will close the PR. In that case just send a reminder to the maintainer (smartins at kde.org).