[cfe-dev] Delayed typo correction is fragile

Ilya Biryukov via cfe-dev cfe-dev at lists.llvm.org
Mon Jul 15 11:19:11 PDT 2019

Hi cfe-dev,

In clangd, we often hit the following assertion in the Sema's destructor:
    assert(DelayedTypos.empty() && "Uncorrected typos!");

It's purpose seems to be to indicate that there are places that should call
CorrectDelayedTypos* and forget to do so.

However, when the assertion fires it's hard to track down the exact place
where the CorrectDelayedTypos* call should be inserted. Moreover, it never
fires in normal clang executions because the driver passes -disable-free by
default, which stops Sema's destructor from running.

That leaves clangd and libclang in an unfortunate situation of being the
only clients that experience crashes (apart from lit that run clang -cc1
mode and don't pass -disable-free).

We would like to avoid assertion failures for those, which leads me to the
following questions:
- Is there a way to quickly track down the place that miss the
CorrectDelayedTypos* call?
- If no, would it be ok to turn this assertion into some kind of debug-only
warning and
  document that some typos are never actually corrected due to limitations?
- Even broader, are there any ideas for an alternative design that would be
more resilient to
  changes in the codebase?
  E.g. no delayed typo corrections or easy-to-audit places that should run
CorrectDelayedTypos*, etc.

Ilya Biryukov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190715/48df9919/attachment.html>

More information about the cfe-dev mailing list