[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 12 03:36:17 PDT 2024


alexfh wrote:

Hi @mizvekov, we started seeing crashes after this commit.

I'm working on a shareable test case, but here's the assertion failure and the stack trace:
```
assert.h assertion failed at llvm-project/clang/lib/AST/TemplateName.cpp:184 in TemplateDecl *clang::TemplateName::getAsTemplateDecl(bool) const: Name.getAsDeducedTemplateName
() == nullptr && "Unexpected canonical DeducedTemplateName; Did you mean to use " "getTemplateDeclAndDefaultArgs instead?"
    @     0x559dafb2e734  __assert_fail
    @     0x559dac2d2534  clang::TemplateName::getAsTemplateDecl()
    @     0x559dab8f5744  (anonymous namespace)::TemplateInstantiator::TransformTemplateName()
    @     0x559dab94e9a2  clang::TreeTransform<>::TransformTemplateSpecializationType()
    @     0x559dab8e7f9f  clang::TreeTransform<>::TransformType()
    @     0x559dab94ad68  clang::TreeTransform<>::TransformElaboratedType()
    @     0x559dab8e80a5  clang::TreeTransform<>::TransformType()
    @     0x559dab8e7a0b  clang::TreeTransform<>::TransformType()
    @     0x559dab8e8790  clang::TreeTransform<>::TransformType()
    @     0x559dab8e8690  clang::Sema::SubstType()
    @     0x559dab6f4796  clang::Sema::CheckTemplateIdType()
    @     0x559dab94a6d1  clang::TreeTransform<>::TransformDependentTemplateSpecializationType()
    @     0x559dab8e815f  clang::TreeTransform<>::TransformType()
    @     0x559dab8e8ebe  clang::Sema::SubstFunctionDeclType()
    @     0x559dab985787  clang::TemplateDeclInstantiator::SubstFunctionType()
    @     0x559dab98386d  clang::TemplateDeclInstantiator::VisitFunctionDecl()
    @     0x559dab9de2f3  llvm::function_ref<>::callback_fn<>()
    @     0x559daace13df  clang::Sema::runWithSufficientStackSpace()
    @     0x559dab98e1c8  clang::Sema::SubstDecl()
    @     0x559dab7d6bc1  clang::Sema::FinishTemplateArgumentDeduction()
    @     0x559dab866702  llvm::function_ref<>::callback_fn<>()
    @     0x559daace13df  clang::Sema::runWithSufficientStackSpace()
    @     0x559dab7da125  clang::Sema::DeduceTemplateArguments()
    @     0x559dab64655f  clang::Sema::AddTemplateOverloadCandidate()
    @     0x559dab65b2e4  AddOverloadedCallCandidate()
    @     0x559dab65b167  clang::Sema::AddOverloadedCallCandidates()
    @     0x559dab65b735  clang::Sema::buildOverloadedCallSet()
    @     0x559dab65bb92  clang::Sema::BuildOverloadedCallExpr()
    @     0x559dab13092c  clang::Sema::BuildCallExpr()
    @     0x559dab14af37  clang::Sema::ActOnCallExpr()
    @     0x559daa9f72b4  clang::Parser::ParsePostfixExpressionSuffix()
    @     0x559daa9f9078  clang::Parser::ParseCastExpression()
    @     0x559daa9f44b2  clang::Parser::ParseAssignmentExpression()
    @     0x559daaa4f9a0  clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes()
    @     0x559daaa4cf26  clang::Parser::ParseDeclGroup()
    @     0x559daaa4b310  clang::Parser::ParseSimpleDeclaration()
    @     0x559daaa4aa30  clang::Parser::ParseDeclaration()
    @     0x559daaa96433  clang::Parser::ParseStatementOrDeclarationAfterAttributes()
    @     0x559daaa9428e  clang::Parser::ParseStatementOrDeclaration()
    @     0x559daaa9f8f3  clang::Parser::ParseCompoundStatementBody()
    @     0x559daaa94f57  clang::Parser::ParseStatementOrDeclarationAfterAttributes()
    @     0x559daaa9428e  clang::Parser::ParseStatementOrDeclaration()
    @     0x559daaa9b8c0  clang::Parser::ParseForStatement()
    @     0x559daaa94e07  clang::Parser::ParseStatementOrDeclarationAfterAttributes()
    @     0x559daaa9428e  clang::Parser::ParseStatementOrDeclaration()
    @     0x559daaa9f8f3  clang::Parser::ParseCompoundStatementBody()
    @     0x559daaa94f57  clang::Parser::ParseStatementOrDeclarationAfterAttributes()
    @     0x559daaa9428e  clang::Parser::ParseStatementOrDeclaration()
    @     0x559daaa9b8c0  clang::Parser::ParseForStatement()
    @     0x559daaa94e07  clang::Parser::ParseStatementOrDeclarationAfterAttributes()
    @     0x559daaa9428e  clang::Parser::ParseStatementOrDeclaration()
    @     0x559daaa9f8f3  clang::Parser::ParseCompoundStatementBody()
    @     0x559daaa94f57  clang::Parser::ParseStatementOrDeclarationAfterAttributes()
    @     0x559daaa9428e  clang::Parser::ParseStatementOrDeclaration()
    @     0x559daaa9b8c0  clang::Parser::ParseForStatement()
    @     0x559daaa94e07  clang::Parser::ParseStatementOrDeclarationAfterAttributes()
    @     0x559daaa9428e  clang::Parser::ParseStatementOrDeclaration()
    @     0x559daaa9f8f3  clang::Parser::ParseCompoundStatementBody()
    @     0x559daaaa0c70  clang::Parser::ParseFunctionStatementBody()
    @     0x559daa9d361c  clang::Parser::ParseFunctionDefinition()
    @     0x559daaa4d89b  clang::Parser::ParseDeclGroup()
    @     0x559daa9d1ea8  clang::Parser::ParseDeclOrFunctionDefInternal()
    @     0x559daa9d13d2  clang::Parser::ParseDeclarationOrFunctionDefinition()
    @     0x559daa9d0106  clang::Parser::ParseExternalDeclaration()
    @     0x559daaa1fba7  clang::Parser::ParseInnerNamespace()
    @     0x559daaa1eee4  clang::Parser::ParseNamespace()
    @     0x559daaa4ac0c  clang::Parser::ParseDeclaration()
    @     0x559daa9cfc6a  clang::Parser::ParseExternalDeclaration()
    @     0x559daaa1fba7  clang::Parser::ParseInnerNamespace()
    @     0x559daaa1eee4  clang::Parser::ParseNamespace()
    @     0x559daaa4ac0c  clang::Parser::ParseDeclaration()
    @     0x559daa9cfc6a  clang::Parser::ParseExternalDeclaration()
    @     0x559daaa1fba7  clang::Parser::ParseInnerNamespace()
    @     0x559daaa1eee4  clang::Parser::ParseNamespace()
    @     0x559daaa4ac0c  clang::Parser::ParseDeclaration()
    @     0x559daa9cfc6a  clang::Parser::ParseExternalDeclaration()
    @     0x559daa9ce198  clang::Parser::ParseTopLevelDecl()
    @     0x559daa9c96cf  clang::ParseAST()
    @     0x559daa6df6f4  clang::FrontendAction::Execute()
    @     0x559daa64c719  clang::CompilerInstance::ExecuteAction()
    @     0x559da93ccb6f  clang::ExecuteCompilerInvocation()
    @     0x559da93c9961  cc1_main()
    @     0x559da93bbd73  ExecuteCC1Tool()
    @     0x559daa82c5f8  llvm::function_ref<>::callback_fn<>()
    @     0x559daf9bc0a1  llvm::CrashRecoveryContext::RunSafely()
    @     0x559daa82bbe1  clang::driver::CC1Command::Execute()
    @     0x559daa7eb126  clang::driver::Compilation::ExecuteCommand()
    @     0x559daa7eb45c  clang::driver::Compilation::ExecuteJobs()
    @     0x559daa807322  clang::driver::Driver::ExecuteCompilation()
    @     0x559da93bb3d2  clang_main()
    @     0x559da93b963e  main
    @     0x7f7e14d5b3d4  __libc_start_main
    @     0x559da93b952a  _start
```

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


More information about the cfe-commits mailing list