<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/94928>94928</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`-ast-dump-decl-types` crashes on codes involving concepts
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c++20,
clang:frontend,
concepts
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
zyn0217
</td>
</tr>
</table>
<pre>
<details><summary>backtrace</summary>
<p>
```
clang++: /root/llvm-project/llvm/include/llvm/Support/Casting.h:662: decltype(auto) llvm::dyn_cast(From*) [with To = clang::ValueDecl; From = clang::Decl]: Assertion `detail::isPresent(Val) && "dyn_cast on a non-existent value"' failed.
#0 0x0000000003a01968 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a01968)
#1 0x00000000039ff64c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x39ff64c)
#2 0x0000000003948068 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007a2c9c642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007a2c9c6969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007a2c9c642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007a2c9c6287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007a2c9c62871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x00007a2c9c639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00000000045cb5a5 (anonymous namespace)::ASTPrinter::print(clang::Decl*) ASTConsumers.cpp:0:0
#10 0x00000000045cd6ef (anonymous namespace)::ASTPrinter::TraverseDecl(clang::Decl*) ASTConsumers.cpp:0:0
#11 0x00000000045cda6a clang::RecursiveASTVisitor<(anonymous namespace)::ASTPrinter>::TraverseDeclContextHelper(clang::DeclContext*) (.part.0) ASTConsumers.cpp:0:0
#12 0x00000000045d72f9 clang::RecursiveASTVisitor<(anonymous namespace)::ASTPrinter>::TraverseTranslationUnitDecl(clang::TranslationUnitDecl*) ASTConsumers.cpp:0:0
#13 0x00000000045cd670 (anonymous namespace)::ASTPrinter::TraverseDecl(clang::Decl*) ASTConsumers.cpp:0:0
#14 0x000000000635b0ac clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x635b0ac)
...
```
</p>
</details>
Code:
```cpp
namespace ns {
template <typename T>
concept C = true;
} // namespace ns
using ns::C;
template <typename T> concept Foo = C<T>;
template <C... T, C auto U>
auto FooFunc(C auto V) -> C decltype(auto) {
C auto W = V;
return W;
}
```
Command line:
```
-std=c++20 -Xclang -ast-dump -Xclang -ast-dump-decl-types -Xclang -ast-dump-filter="Foo"
```
https://godbolt.org/z/ebcMq8b4e
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEV1tz2ygU_jX4hbEGga4PfnDkavqys53GTfctgxC22SDQAnLj_vodkG9y3J1mpzubcRIDh_N95wYHaq3YKs4XIH0A6WpGB7fTZvH9oBCO81mj28MCkKrljgppAfkASGWHrqPmAMiHhrIXZyjjgFQA15cFgFYALQGp-stg_Juh4ycMmaRqC_CD_5AlBLg2WjuAayn33bw3-k_OTkOAa6GYHFp-mXgc-l4bL1FR64TaRjtAllmGvbaWM-kOPQe4oIPTAJcwbCNLQJbtQT0zah3ARW10B_DSr4P04ZtwO7jWEJAVHOkF-ScqB77iTALyAP2OW4Gwlq488NJabpzQCoIMja4bZYT9ZLjlyqM-URkQcQZwBgHGJ0ZQK0ih0mrOX4V1XDm49-AAY4BzuKFC8ja6dioEmCCIXtHph1AUl1lxZa492PHLJyOUe3SUvaxD4HBxETL027O2znDaBVoVFJ6qJ1kAXOveO5rprheSmzl_7aU23Pg574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