This tries to solve https://github.com/llvm/llvm-project/issues/52857.
Simply, the key reason is the unnamed class might be externally visible too in c++ modules! It is a little bit surprising to me at the first sight. Since how can an entity without a name to be visible. However, I recognize that it should be so otherwise the optimizer would lose a chance to do IPO (interprocedural optimization, like inlining). The corresponding code would be: https://github.com/llvm/llvm-project/blob/d29e319263de17516f50cd46edbf1e62c1289dd4/clang/lib/AST/Decl.cpp#L1258-L1259.
So I think we didn't met the problem before we introduces C++ modules since we didn't met externally visible unnamed class before.
To my understanding, changing the behavior of mangler is not trivial. It matters to ABI compatibility and other many tools like demangler and debugger. So I marked this one as RFC although it doesn't contain many codes.