clang-tidy slow without --

I have managed to build a release version of clang-tidy on my Mac, and checked that it is optimized with --version.

~/llvm-build/bin/clang-tidy --version

LLVM (http://llvm.org/):
LLVM version 3.8.0svn
Optimized build.
Built Jan 15 2016 (13:18:26).
Default target: x86_64-apple-darwin15.0.0
Host CPU: broadwell

I am working with an Objective-C project in Xcode, and have managed to generate the required compile_commands.json file using xcodebuild/xcpretty, and am able to run it.

When I run it on a single file that has 2700 lines with just the compile_commands.json file (stripped down to just one command), it takes clang-tidy around 23 seconds to complete.

~/llvm-build/bin/clang-tidy MyFile.m


Suppressed 719 warnings (719 in non-user code).
Use -header-filter=.* to display errors from all non-system headers.

If I run the same command with “–”, then it is much faster.

~/llvm-build/bin/clang-tidy MyFile.m –

Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers.

It seems the difference is that with --, some header files aren’t processed? If I am just interested in errors in the specific file I am running on, is using – the right thing to do?

Thanks,
Hongping

Actually it seems “–” without anything after just means to not have any compile options at all?

I went through the options in my compile_command.json file, and it seems this isysroot option is what is causing the command to be slow for this particular source file. If I remove it then the command runs quickly.

-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk

However, with the same compile options including the above isysroot option, running on another source file that I have which is 2200 lines, and causes 735 warnings in non-user code as well, clang-tidy takes less than one second.

Thanks,
Hongping

Actually it seems “–” without anything after just means to not have any compile options at all?

I went through the options in my compile_command.json file, and it seems this isysroot option is what is causing the command to be slow for this particular source file. If I remove it then the command runs quickly.

-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk

However, with the same compile options including the above isysroot option, running on another source file that I have which is 2200 lines, and causes 735 warnings in non-user code as well, clang-tidy takes less than one second.

  1. If you don’t have the right isysroot, you probably get actual compiler errors, and clang-tidy checks will not run
  2. It might be that the transitive closure of includes is just very large when the TU takes long to process, but that’d need some more detailed benchmarking
  1. If you don’t have the right isysroot, you probably get actual compiler errors, and clang-tidy checks will not run
  2. It might be that the transitive closure of includes is just very large when the TU takes long to process, but that’d need some more detailed benchmarking

Thanks for the reply.

Is there some way to list the headers processed, and how much time they incur?

I tried copying all the #imports used by the file that takes a longer time into the file that takes less time, and the amount of time taken didn’t change. It seems the actual code used in the source file might also affect which header files are processed?

Thanks,
Hongping

It seems the time might be spent running the analyzer, which is reported to be slower than compilation (http://clang-analyzer.llvm.org/ ).

For now, I am using -clang-analyzer-* to disable these checks.

Thanks,
Hongping

[Please reply *only* to the list and do not include my email directly
in the To: or Cc: of your reply; otherwise I will not see your reply.
Thanks.]

In article <CAOvxy8_Z9DgAPPKvq0XRtMt-1GBjuoYGaBOEvDnGKMqDUy1qdQ@mail.gmail.com>,
    Hongping Lim via cfe-dev <cfe-dev@lists.llvm.org> writes:

For now, I am using -clang-analyzer-* to disable these checks.

I typically run with '-checks=-*,...' to only enable exactly the
checks that I want to run when I'm in "refactoring" mode. If I am in
"static analysis mode" then I run with lots of checks enabled and
expect the processing to be slow.