[PATCH] D78715: [clangd] Fix modernize-loop-convert "multiple diag in flight" crash.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 23 08:04:44 PDT 2020


sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Ah, nice work!
Agree it's a hack (and how many more instances are lurking) but I don't know how better to fix it and it's been reported 3 times...



================
Comment at: clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp:529
+  // getTypeInfo may emit a diagnostic, we have to call it before constructing
+  // the Diag to avoid the "multiple-diagnostic in flight" crash in clangd.
+  auto TypeWidth = Context->getTypeInfo(Descriptor.ElemType).Width;
----------------
I'm not sure we need to mention clangd here - I'd expect standalone clang-tidy to be able to hit the same condition?
At least logically I think the bug exists either way.


================
Comment at: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp:275
 
+TEST(DiagnosticTest, NoMultipleDiagnosticInFlight) {
+  Annotations Main(R"cpp(
----------------
Does the bug repro with clang-tidy? If so it'd be nice to make this a clang-tidy test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78715/new/

https://reviews.llvm.org/D78715





More information about the cfe-commits mailing list