Hacker News new | ask | show | jobs
by CoolGuySteve 2231 days ago
My project uses g++ but I’ve been using a clang static-analysis step in my CI pipeline for a while now.

Compiling with clang is much, much slower but it finds interesting errors sometimes. I only had to ifdef out one code section that it couldn’t understand (something about indexing an array with a constexpr function returning an enum class from a template parameter).

It depends on the project, but this one and another project I made work are both 100k lines of C++ and took half a day to setup. It was worth it imo.

1 comments

Interesting that your build times are slower with clang. I've found on most of my projects clang is roughly 30% faster to compile in debug, but release I haven't seen a huge difference between the two.
My build times are identical between GCC and Clang (debug and release).

But TCC is 10x faster than both of them.

Perhaps they are slower because Clang is doing static analysis in this case.
Static analysis is a lot slower but regular clang++ is also significantly slower than g++, like a 4-5 minute build time vs 2:30 on g++.

It might have something to do with a heavy usage of templates in a few files, I don't know.

Clang's autovectorization is better in a few functions I disassembled but otherwise the generated code doesn't benchmark any faster, it's better in some places, worse in others.

Nope, also slower for me.