[clang] [clang-tools-extra] [clangd] [AST] Handle uninitialized type constraints (PR #110496)

Florian Albrechtskirchinger via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 30 10:19:11 PDT 2024


falbrechtskirchinger wrote:

> Thanks again for analyzing & working on this issue.

You’re very welcome! Let's hope I'm on the right track.

> Some suggestions regarding the test:
> 
>     1. As this is more of a clang issue (the offending code belongs to the serialization part of clang), so it is more appropriate to write a clang test instead of a clangd test.
> 
>     2. We don't usually write lit tests but rather unit tests (specifically, tests under the `clangd/unittests` directory) for clangd.

The most recent push contains a clangd unit test. I'd argue that replicating the test logic present in clangd (`TestTU`, `ParsedAST`) in clang unit tests is unnecessary. Also, the error is specific to clangd. No one has proposed a method of triggering the assertion using clang directly.

I've verified that the test triggers the assertion without the changes introduced in this PR.
```txt
[ RUN      ] ClangdAST.HandleUninitializedTypeConstraints
ClangdTests: /data6/git/llvm-project/clang/lib/Serialization/ASTWriterDecl.cpp:1902: void clang::ASTDeclWriter::VisitTemplateTypeParmDecl(clang::TemplateTypeParmDecl*): Assertion `(bool)TC == D->hasTypeConstraint()' failed.
```

If you insist on a clang unit test, I'll need help. :)






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


More information about the cfe-commits mailing list