Assertion failure when mangling complex decltype

Hi all,

On release_70, for the example code:

#include <type_traits>
class Node {};
void buildGenericSCCs(GetBeginT &&GetBegin) {
decltype(GetBegin(std::declval<Node &>())) DFSStack;

In Mangle.h when calling mangleCXXName() on VarDecl of DFSStack, assertion triggered:

tools/clang/lib/AST/ItaniumMangle.cpp:4317: void (anonymous namespace)::CXXNameMangler::mangleFunctionParam(const clang::ParmVarDecl *): Assertion `parmDepth < FunctionTypeDepth.getDepth()’ failed.

Do anyone have any ideas on the cause of it? Thanks

Wait, why are we trying to mangle the local var decl here? Doesn’t seem to repro on TOT for me, can you provide a backtrace/preprocessed source/a clang invocation for this?


Reproducible on TOT. Confirmed!


The mangler is only designed to produce mangled names for declarations that have symbols. You cannot expect to be able to pass other declarations to it and get a meaningful result back (or even for it to not crash).

If you want a unique identifier for an arbitrary declaration for some reason, USRs may be a better fit.