llvm / llvm-project

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

Clang spell checker is slow #18072

Open 153465f3-2020-4b1e-8351-d0d14d812a9b opened 10 years ago

153465f3-2020-4b1e-8351-d0d14d812a9b commented 10 years ago
Bugzilla Link 17698
Version trunk
OS Linux
CC @jryans

Extended Description

This test case:

include "boost/asio.hpp"

double mainf(); int mainf() { foo(sdafo_2, 0); return 0; }

takes this time to compile:

Time (seconds) Command 6.8 clang -c -std=c++11 test.cpp 4.8 clang -c test.cpp

(after replacing `sdafo_2' with `x')

1.0 clang -c test.cpp

(after replacing `sdafo_2' with `o_2')

2.8 clang -c test.cpp

Note how Clang needs a long time to compute the diagnostic about sdafo_2' after reporting the diagnostic about the illegal overload ofmainf'.

153465f3-2020-4b1e-8351-d0d14d812a9b commented 10 years ago

Just to add one more data point to this issue: after making a simple change on a C++ source file, clang seemed stuck while compiling it. After 2 minutes I killed the process thinking that it was in a infinite loop. Then remembered this issue and tried to compile with g++. Sure enough, there was a typo introduced by the change. After fixing the typo clang compiled the C++ file in a few seconds.

153465f3-2020-4b1e-8351-d0d14d812a9b commented 10 years ago

-fno-spell-checking makes the slowness go away.

153465f3-2020-4b1e-8351-d0d14d812a9b commented 10 years ago

Forgot to mention that compiling the preprocessed source halves the compile time. That is, preprocessing and then compiling the resulting output takes half the time of compiling the original file.