[clang-tools-extra] [clang-tidy] Fix crash in misc-static-initialization-cycle with clangd (PR #245174)

Aleksandr Platonov via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 23 23:48:24 PST 2026


================
@@ -450,6 +450,26 @@ TEST(DiagnosticsTest, ClangTidyEOF) {
                 diagSource(Diag::ClangTidy), diagName("llvm-include-order")))));
 }
 
+TEST(DiagnosticsTest, ClangTidyStaticInitializationCycleInitInInclude) {
+  Annotations Main(R"cpp(
+    extern int X;
+    int $a[[A]] = A;
+    #include "init.inc"
+  )cpp");
+  auto TU = TestTU::withCode(Main.code());
+  TU.AdditionalFiles["init.inc"] = "int X = X;";
----------------
ArcsinX wrote:

cycle about `X` is not reported in this test.

I played with this a bit and found that there is no crash and `X` cycle is also reported, if I revert your change and remove `llvm_unexpected` ...

https://github.com/llvm/llvm-project/pull/245174


More information about the cfe-commits mailing list