llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.05k stars 11.58k forks source link

`<QVariant>` causes big clang-tidy slowdown #109450

Open firewave opened 2 hours ago

firewave commented 2 hours ago
#include <QVariant>

.clang-tidy

---
Checks: >
        *,
        -abseil-*,
        -altera-*,
        -android-*,
        -boost-*,
        -cert-*,
        -cppcoreguidelines-*,
        -darwin-*,
        -fuchsia-*,
        -google-*,
        -hicpp-*,
        -linuxkernel-*,
        -llvm-*,
        -llvmlibc-*,
        -mpi-*,
        -objc-*,
        -openmp-*,
        -zircon-*,
        cert-err34-c,
        cppcoreguidelines-pro-type-static-cast-downcast,
        cppcoreguidelines-rvalue-reference-param-not-moved,
        google-explicit-constructor,
        -bugprone-assignment-in-if-condition,
        -bugprone-branch-clone,
        -bugprone-easily-swappable-parameters,
        -bugprone-empty-catch,
        -bugprone-macro-parentheses,
        -bugprone-narrowing-conversions,
        -bugprone-signed-char-misuse,
        -bugprone-switch-missing-default-case,
        -bugprone-unchecked-optional-access,
        -clang-analyzer-*,
        -concurrency-mt-unsafe,
        -misc-const-correctness,
        -misc-no-recursion,
        -misc-non-private-member-variables-in-classes,
        -misc-throw-by-value-catch-by-reference,
        -misc-use-anonymous-namespace,
        -modernize-avoid-c-arrays,
        -modernize-deprecated-ios-base-aliases,
        -misc-include-cleaner,
        -misc-unused-using-decls,
        -modernize-loop-convert,
        -modernize-macro-to-enum,
        -modernize-raw-string-literal,
        -modernize-replace-auto-ptr,
        -modernize-return-braced-init-list,
        -modernize-type-traits,
        -modernize-use-auto,
        -modernize-use-designated-initializers,
        -modernize-use-nodiscard,
        -modernize-use-trailing-return-type,
        -performance-avoid-endl,
        -performance-inefficient-string-concatenation,
        -performance-no-automatic-move,
        -portability-simd-intrinsics,
        -portability-std-allocator-const,
        -readability-avoid-nested-conditional-operator,
        -readability-braces-around-statements,
        -readability-container-data-pointer,
        -readability-enum-initial-value,
        -readability-function-cognitive-complexity,
        -readability-function-size,
        -readability-identifier-length,
        -readability-identifier-naming,
        -readability-implicit-bool-conversion,
        -readability-isolate-declaration,
        -readability-magic-numbers,
        -readability-suspicious-call-argument,
        -readability-uppercase-literal-suffix
$ clang-tidy common.cpp --enable-check-profile -- $(pkg-config --cflags-only-I Qt6Core)
===-------------------------------------------------------------------------===
                          clang-tidy checks profiling
===-------------------------------------------------------------------------===
  Total Execution Time: 20.2481 seconds (20.2487 wall clock)

It does not appear to be a single check:

   ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
   0.2992 (  4.3%)   0.6637 (  5.0%)   0.9629 (  4.8%)   0.9630 (  4.8%)  bugprone-stringview-nullptr
   0.2908 (  4.2%)   0.5689 (  4.3%)   0.8597 (  4.2%)   0.8546 (  4.2%)  bugprone-use-after-move
   0.2382 (  3.4%)   0.4826 (  3.6%)   0.7208 (  3.6%)   0.7190 (  3.6%)  bugprone-standalone-empty
   0.2108 (  3.0%)   0.4565 (  3.4%)   0.6673 (  3.3%)   0.6749 (  3.3%)  readability-non-const-parameter
   0.1952 (  2.8%)   0.4015 (  3.0%)   0.5967 (  2.9%)   0.5966 (  2.9%)  readability-container-size-empty
   0.1794 (  2.6%)   0.3919 (  2.9%)   0.5713 (  2.8%)   0.5736 (  2.8%)  readability-redundant-control-flow
   0.1849 (  2.7%)   0.3881 (  2.9%)   0.5730 (  2.8%)   0.5732 (  2.8%)  bugprone-unused-return-value
   0.1779 (  2.6%)   0.3838 (  2.9%)   0.5617 (  2.8%)   0.5650 (  2.8%)  bugprone-suspicious-string-compare
   0.1769 (  2.6%)   0.3742 (  2.8%)   0.5511 (  2.7%)   0.5504 (  2.7%)  bugprone-infinite-loop
   0.1712 (  2.5%)   0.3727 (  2.8%)   0.5439 (  2.7%)   0.5448 (  2.7%)  modernize-use-nullptr
   0.1626 (  2.3%)   0.3733 (  2.8%)   0.5360 (  2.6%)   0.5357 (  2.6%)  modernize-use-transparent-functors
   0.1664 (  2.4%)   0.3590 (  2.7%)   0.5255 (  2.6%)   0.5253 (  2.6%)  performance-move-const-arg
   0.1655 (  2.4%)   0.3583 (  2.7%)   0.5238 (  2.6%)   0.5241 (  2.6%)  bugprone-assert-side-effect
   0.1624 (  2.3%)   0.3531 (  2.7%)   0.5155 (  2.5%)   0.5158 (  2.5%)  bugprone-multiple-statement-macro
   0.1613 (  2.3%)   0.3512 (  2.6%)   0.5124 (  2.5%)   0.5126 (  2.5%)  bugprone-suspicious-semicolon
   0.1561 (  2.3%)   0.3383 (  2.5%)   0.4944 (  2.4%)   0.4948 (  2.4%)  bugprone-unused-raii
   0.4487 (  6.5%)   0.0238 (  0.2%)   0.4725 (  2.3%)   0.4725 (  2.3%)  bugprone-reserved-identifier
   0.1431 (  2.1%)   0.3162 (  2.4%)   0.4593 (  2.3%)   0.4589 (  2.3%)  bugprone-sizeof-expression
   0.1439 (  2.1%)   0.3134 (  2.4%)   0.4573 (  2.3%)   0.4575 (  2.3%)  bugprone-inc-dec-in-conditions
   0.1391 (  2.0%)   0.3045 (  2.3%)   0.4436 (  2.2%)   0.4448 (  2.2%)  bugprone-chained-comparison
   0.1209 (  1.7%)   0.2578 (  1.9%)   0.3787 (  1.9%)   0.3782 (  1.9%)  misc-confusable-identifiers
   0.2194 (  3.2%)   0.0992 (  0.7%)   0.3186 (  1.6%)   0.3181 (  1.6%)  modernize-use-using
   0.0861 (  1.2%)   0.1997 (  1.5%)   0.2858 (  1.4%)   0.2864 (  1.4%)  readability-redundant-declaration
[...]

pkg-config contains -I options for for includes and I manually modified them to -isystem but it does not make any difference.

There are other headers which are also quite slow (e.g. <Qt> and <QFileInfo> ) for just being included but they are not as bad as this one.

I can reproduce this with LLVM 18.1.8 and 19 using Qt 6.7.2. Unfortunately Qt6 is not available on the system I have all my older LLVM versions installed on so I cannot check when/if this is regressed.

llvmbot commented 2 hours ago

@llvm/issue-subscribers-clang-tidy

Author: Oliver Stöneberg (firewave)

```cpp #include <QVariant> ``` `.clang-tidy` ```yml --- Checks: > *, -abseil-*, -altera-*, -android-*, -boost-*, -cert-*, -cppcoreguidelines-*, -darwin-*, -fuchsia-*, -google-*, -hicpp-*, -linuxkernel-*, -llvm-*, -llvmlibc-*, -mpi-*, -objc-*, -openmp-*, -zircon-*, cert-err34-c, cppcoreguidelines-pro-type-static-cast-downcast, cppcoreguidelines-rvalue-reference-param-not-moved, google-explicit-constructor, -bugprone-assignment-in-if-condition, -bugprone-branch-clone, -bugprone-easily-swappable-parameters, -bugprone-empty-catch, -bugprone-macro-parentheses, -bugprone-narrowing-conversions, -bugprone-signed-char-misuse, -bugprone-switch-missing-default-case, -bugprone-unchecked-optional-access, -clang-analyzer-*, -concurrency-mt-unsafe, -misc-const-correctness, -misc-no-recursion, -misc-non-private-member-variables-in-classes, -misc-throw-by-value-catch-by-reference, -misc-use-anonymous-namespace, -modernize-avoid-c-arrays, -modernize-deprecated-ios-base-aliases, -misc-include-cleaner, -misc-unused-using-decls, -modernize-loop-convert, -modernize-macro-to-enum, -modernize-raw-string-literal, -modernize-replace-auto-ptr, -modernize-return-braced-init-list, -modernize-type-traits, -modernize-use-auto, -modernize-use-designated-initializers, -modernize-use-nodiscard, -modernize-use-trailing-return-type, -performance-avoid-endl, -performance-inefficient-string-concatenation, -performance-no-automatic-move, -portability-simd-intrinsics, -portability-std-allocator-const, -readability-avoid-nested-conditional-operator, -readability-braces-around-statements, -readability-container-data-pointer, -readability-enum-initial-value, -readability-function-cognitive-complexity, -readability-function-size, -readability-identifier-length, -readability-identifier-naming, -readability-implicit-bool-conversion, -readability-isolate-declaration, -readability-magic-numbers, -readability-suspicious-call-argument, -readability-uppercase-literal-suffix ``` ``` $ clang-tidy common.cpp --enable-check-profile -- $(pkg-config --cflags-only-I Qt6Core) ===-------------------------------------------------------------------------=== clang-tidy checks profiling ===-------------------------------------------------------------------------=== Total Execution Time: 20.2481 seconds (20.2487 wall clock) ``` It does not appear to be a single check: ``` ---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name --- 0.2992 ( 4.3%) 0.6637 ( 5.0%) 0.9629 ( 4.8%) 0.9630 ( 4.8%) bugprone-stringview-nullptr 0.2908 ( 4.2%) 0.5689 ( 4.3%) 0.8597 ( 4.2%) 0.8546 ( 4.2%) bugprone-use-after-move 0.2382 ( 3.4%) 0.4826 ( 3.6%) 0.7208 ( 3.6%) 0.7190 ( 3.6%) bugprone-standalone-empty 0.2108 ( 3.0%) 0.4565 ( 3.4%) 0.6673 ( 3.3%) 0.6749 ( 3.3%) readability-non-const-parameter 0.1952 ( 2.8%) 0.4015 ( 3.0%) 0.5967 ( 2.9%) 0.5966 ( 2.9%) readability-container-size-empty 0.1794 ( 2.6%) 0.3919 ( 2.9%) 0.5713 ( 2.8%) 0.5736 ( 2.8%) readability-redundant-control-flow 0.1849 ( 2.7%) 0.3881 ( 2.9%) 0.5730 ( 2.8%) 0.5732 ( 2.8%) bugprone-unused-return-value 0.1779 ( 2.6%) 0.3838 ( 2.9%) 0.5617 ( 2.8%) 0.5650 ( 2.8%) bugprone-suspicious-string-compare 0.1769 ( 2.6%) 0.3742 ( 2.8%) 0.5511 ( 2.7%) 0.5504 ( 2.7%) bugprone-infinite-loop 0.1712 ( 2.5%) 0.3727 ( 2.8%) 0.5439 ( 2.7%) 0.5448 ( 2.7%) modernize-use-nullptr 0.1626 ( 2.3%) 0.3733 ( 2.8%) 0.5360 ( 2.6%) 0.5357 ( 2.6%) modernize-use-transparent-functors 0.1664 ( 2.4%) 0.3590 ( 2.7%) 0.5255 ( 2.6%) 0.5253 ( 2.6%) performance-move-const-arg 0.1655 ( 2.4%) 0.3583 ( 2.7%) 0.5238 ( 2.6%) 0.5241 ( 2.6%) bugprone-assert-side-effect 0.1624 ( 2.3%) 0.3531 ( 2.7%) 0.5155 ( 2.5%) 0.5158 ( 2.5%) bugprone-multiple-statement-macro 0.1613 ( 2.3%) 0.3512 ( 2.6%) 0.5124 ( 2.5%) 0.5126 ( 2.5%) bugprone-suspicious-semicolon 0.1561 ( 2.3%) 0.3383 ( 2.5%) 0.4944 ( 2.4%) 0.4948 ( 2.4%) bugprone-unused-raii 0.4487 ( 6.5%) 0.0238 ( 0.2%) 0.4725 ( 2.3%) 0.4725 ( 2.3%) bugprone-reserved-identifier 0.1431 ( 2.1%) 0.3162 ( 2.4%) 0.4593 ( 2.3%) 0.4589 ( 2.3%) bugprone-sizeof-expression 0.1439 ( 2.1%) 0.3134 ( 2.4%) 0.4573 ( 2.3%) 0.4575 ( 2.3%) bugprone-inc-dec-in-conditions 0.1391 ( 2.0%) 0.3045 ( 2.3%) 0.4436 ( 2.2%) 0.4448 ( 2.2%) bugprone-chained-comparison 0.1209 ( 1.7%) 0.2578 ( 1.9%) 0.3787 ( 1.9%) 0.3782 ( 1.9%) misc-confusable-identifiers 0.2194 ( 3.2%) 0.0992 ( 0.7%) 0.3186 ( 1.6%) 0.3181 ( 1.6%) modernize-use-using 0.0861 ( 1.2%) 0.1997 ( 1.5%) 0.2858 ( 1.4%) 0.2864 ( 1.4%) readability-redundant-declaration [...] ``` `pkg-config` contains `-I` options for for includes and I manually modified them to `-isystem` but it does not make any difference. There are other headers which are also quite slow (e.g. `<Qt>` and `<QFileInfo>` ) for just being included but they are not as bad as this one. I can reproduce this with LLVM 18.1.8 and 19 using Qt 6.7.2. Unfortunately Qt6 is not available on the system I have all my older LLVM versions installed on so I cannot check when/if this is regressed.