<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/82222>82222</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            `clang --analyze` is slow
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          jirislaby
      </td>
    </tr>
</table>

<pre>
    I have a [static checker to collect structs+members](https://github.com/jirislaby/clang-struct) of the Linux kernel.

I have `compile_commands.json` with properly defined command line for each file, so if I put the command line into an array `cmdline`, I can do:
```sh
clang "${cmdline[@]}" -E | clang -cc1  -analyze -load clang-struct.so -analyzer-checker jirislaby.StructMembersChecker
```

But this is not right as (for example) the second `clang` needs to know about `-fshort-wchar` from the former (from `cmdline`), otherwise I see errors like:
```
arch/x86/platform/efi/quirks.c:80:27: error: initializing wide char array with incompatible wide string literal
   80 | static const efi_char16_t efi_dummy_name[] = L"DUMMY";
```

I can go closer with **one** `clang` process using `--analyze`:

```sh
clang "${cmdline[@]}" --analyze --analyzer-no-default-checks -Xclang -load -Xclang clang-struct.so \
    -Xclang -analyzer-checker -Xclang jirislaby.StructMembersChecker
```

But while the former (*piped*) `clang` takes 1,3 s real time, the latter takes 3,5 s.

Is this a bug in `--analyze` switch (so that it compiles the result too) or is the command line wrong?

`compile_commands.json` entry for the above example:
```json
  {
    "command": "clang -Wp,-MMD,arch/x86/platform/efi/.quirks.o.d -nostdinc -I/mnt/storage/xslaby/linux/arch/x86/include -I./arch/x86/include/generated -I/mnt/storage/xslaby/linux/include -I./include -I/mnt/storage/xslaby/linux/arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I/mnt/storage/xslaby/linux/include/uapi -I./include/generated/uapi -include /mnt/storage/xslaby/linux/include/linux/compiler-version.h -include /mnt/storage/xslaby/linux/include/linux/kconfig.h -include /mnt/storage/xslaby/linux/include/linux/compiler_types.h -D__KERNEL__ --target=x86_64-linux-gnu -fintegrated-as -Werror=unknown-warning-option -Werror=ignored-optimization-argument -Werror=option-ignored -Werror=unused-command-line-argument -fmacro-prefix-map=/mnt/storage/xslaby/linux/= -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=branch -fno-jump-tables -m64 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mstack-alignment=8 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -Wno-sign-compare -fno-asynchronous-unwind-tables -mretpoline-external-thunk -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -Os -fstack-protector-strong -ftrivial-auto-var-init=zero -fno-stack-clash-protection -pg -mfentry -DCC_USING_NOP_MCOUNT -DCC_USING_FENTRY -falign-functions=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -Wall -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wframe-larger-than=2048 -Wno-gnu -Wno-unused-but-set-variable -Wno-unused-const-variable -Wvla -Wno-pointer-sign -Wcast-function-type -Wimplicit-fallthrough -Werror=date-time -Werror=incompatible-pointer-types -Wenum-conversion -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-pointer-to-enum-cast -Wno-tautological-constant-out-of-range-compare -Wno-unaligned-access -Wno-cast-function-type-strict -Wno-missing-field-initializers -Wno-type-limits -Wno-shift-negative-value -Wno-initializer-overrides -Wno-sign-compare -I /mnt/storage/xslaby/linux/arch/x86/platform/efi -I ./arch/x86/platform/efi -DKBUILD_MODFILE='\"arch/x86/platform/efi/quirks\"' -DKBUILD_BASENAME='\"quirks\"' -DKBUILD_MODNAME='\"quirks\"' -D__KBUILD_MODNAME=kmod_quirks -c -o arch/x86/platform/efi/quirks.o /mnt/storage/xslaby/linux/arch/x86/platform/efi/quirks.c",
 "directory": "/mnt/storage/xslaby/cl",
    "file": "/mnt/storage/xslaby/linux/arch/x86/platform/efi/quirks.c"
  },
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykWN1uIysSfhpyU8Ky6fgnF7lI3PHKOpPM0Zkzyp4rC9PV3Yxp6AXajufpV0D7L9FkMxtpNKGhqCq--qgqzJ2TlUa8JeN7Ms6veOdrY29_SCud4uv91doU-9sl1HyLwIGM753nXgoQNYoNWvAGhFEKhQfnbSe8I-y-wWaN1pFxTtis9r51JLsjbEHYopK-7tYDYRrCFkczhC2E4rqiSQdhN2BK8DXCF6m7F9ig1agGZJiT4V36v_eJTIbCNK1UuBKmabgu3OCHM5pMhrCTvobWmhat2kOBpdRYQC8GSmqE0lhALmoopULC5uAMyBKW0HY-2r-Qltob4Bq4tXwfTTdFWCCTYdi7BME1FCYcNnk6GaZ_rk4T8ZBAGCPsmkzvD9vH9-R6GNCa5oQxoA9ApnNIwlSIEQDlmqv9TwSqDC_gHKyBM8dlSw9xOUI7-BalHlNI5mn5lXvnuN7Hg0sH0oE2Hqysag_cAWGziNYLb9qA1U3Ex6EwuohYBJ8C7BqxcIEYG212wNem82Gdlq421tOdqLkNcqU1TdRRGtugjQbC1CtcbwK0xtdod9IhLMEhAlprrAMlN_gW7fTJragJW7zMJoQtWsV9MEPYAktJ2OI_nbQbNxAku5sNSXbHpiS7S2rDQGrpJVfyp9QV7GSBELzuAx95JXXgHfdyrTBJOG-DtJIeLVfJCQCYDWM0D_fGaOcBS7kKCkeTVfoouqbZrzRvMF1EIFkOXwhj-ffHx38CYbL7d4KWmFcZEMo4tMlDwu4IuzMa0-AiRq01Ap2DzgWXQ3QOFAqaj4h-isUnzp7oqQ0tsOSd8ompDui_e55HYh--XhOcjOdHQE9b3rD-sPIp9u9qqfAVMQm7a2WLRYTy5gJKzzfoYETYPAMHFrkCL5uYTIIOxb0PeTJKZ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