[PATCH] D136259: Fix crash in constraining partial specialization on nested template.
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG4c87e12484b3: Fix crash in constraining partial specialization on nested template. (authored by usaxena95). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D136259/new/ https://reviews.llvm.org/D136259 Files: clang/lib/Sema/SemaTemplateDeduction.cpp clang/test/SemaTemplate/concepts-GH53354.cpp Index: clang/test/SemaTemplate/concepts-GH53354.cpp === --- /dev/null +++ clang/test/SemaTemplate/concepts-GH53354.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -std=c++20 -verify %s +// expected-no-diagnostics + +template class> +struct S +{}; + +template +concept C1 = requires +{ + typename S; +}; + +template +requires C1 +struct A {}; + +template +requires C1 && true +struct A {}; Index: clang/lib/Sema/SemaTemplateDeduction.cpp === --- clang/lib/Sema/SemaTemplateDeduction.cpp +++ clang/lib/Sema/SemaTemplateDeduction.cpp @@ -5803,8 +5803,8 @@ } bool TraverseTemplateName(TemplateName Template) { -if (auto *TTP = -dyn_cast(Template.getAsTemplateDecl())) +if (auto *TTP = llvm::dyn_cast_or_null( +Template.getAsTemplateDecl())) if (TTP->getDepth() == Depth) Used[TTP->getIndex()] = true; RecursiveASTVisitor:: Index: clang/test/SemaTemplate/concepts-GH53354.cpp === --- /dev/null +++ clang/test/SemaTemplate/concepts-GH53354.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -std=c++20 -verify %s +// expected-no-diagnostics + +template class> +struct S +{}; + +template +concept C1 = requires +{ + typename S; +}; + +template +requires C1 +struct A {}; + +template +requires C1 && true +struct A {}; Index: clang/lib/Sema/SemaTemplateDeduction.cpp === --- clang/lib/Sema/SemaTemplateDeduction.cpp +++ clang/lib/Sema/SemaTemplateDeduction.cpp @@ -5803,8 +5803,8 @@ } bool TraverseTemplateName(TemplateName Template) { -if (auto *TTP = -dyn_cast(Template.getAsTemplateDecl())) +if (auto *TTP = llvm::dyn_cast_or_null( +Template.getAsTemplateDecl())) if (TTP->getDepth() == Depth) Used[TTP->getIndex()] = true; RecursiveASTVisitor:: ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D136259: Fix crash in constraining partial specialization on nested template.
ilya-biryukov accepted this revision. ilya-biryukov added a comment. This revision is now accepted and ready to land. LGTM, thanks! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D136259/new/ https://reviews.llvm.org/D136259 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D136259: Fix crash in constraining partial specialization on nested template.
usaxena95 updated this revision to Diff 468962. usaxena95 marked 2 inline comments as done. usaxena95 added a comment. Addressed comments. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D136259/new/ https://reviews.llvm.org/D136259 Files: clang/lib/Sema/SemaTemplateDeduction.cpp clang/test/SemaTemplate/concepts-GH53354.cpp Index: clang/test/SemaTemplate/concepts-GH53354.cpp === --- /dev/null +++ clang/test/SemaTemplate/concepts-GH53354.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -std=c++20 -verify %s +// expected-no-diagnostics + +template class> +struct S +{}; + +template +concept C1 = requires +{ + typename S; +}; + +template +requires C1 +struct A {}; + +template +requires C1 && true +struct A {}; Index: clang/lib/Sema/SemaTemplateDeduction.cpp === --- clang/lib/Sema/SemaTemplateDeduction.cpp +++ clang/lib/Sema/SemaTemplateDeduction.cpp @@ -5804,8 +5804,8 @@ } bool TraverseTemplateName(TemplateName Template) { -if (auto *TTP = -dyn_cast(Template.getAsTemplateDecl())) +if (auto *TTP = llvm::dyn_cast_or_null( +Template.getAsTemplateDecl())) if (TTP->getDepth() == Depth) Used[TTP->getIndex()] = true; RecursiveASTVisitor:: Index: clang/test/SemaTemplate/concepts-GH53354.cpp === --- /dev/null +++ clang/test/SemaTemplate/concepts-GH53354.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -std=c++20 -verify %s +// expected-no-diagnostics + +template class> +struct S +{}; + +template +concept C1 = requires +{ + typename S; +}; + +template +requires C1 +struct A {}; + +template +requires C1 && true +struct A {}; Index: clang/lib/Sema/SemaTemplateDeduction.cpp === --- clang/lib/Sema/SemaTemplateDeduction.cpp +++ clang/lib/Sema/SemaTemplateDeduction.cpp @@ -5804,8 +5804,8 @@ } bool TraverseTemplateName(TemplateName Template) { -if (auto *TTP = -dyn_cast(Template.getAsTemplateDecl())) +if (auto *TTP = llvm::dyn_cast_or_null( +Template.getAsTemplateDecl())) if (TTP->getDepth() == Depth) Used[TTP->getIndex()] = true; RecursiveASTVisitor:: ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D136259: Fix crash in constraining partial specialization on nested template.
ilya-biryukov added inline comments. Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:5807 bool TraverseTemplateName(TemplateName Template) { -if (auto *TTP = -dyn_cast(Template.getAsTemplateDecl())) - if (TTP->getDepth() == Depth) -Used[TTP->getIndex()] = true; +if (TemplateDecl *TD = Template.getAsTemplateDecl()) + if (auto *TTP = dyn_cast(TD)) NIT: maybe keep a single if statement and use `dyn_cast_or_null`? Comment at: clang/test/SemaTemplate/concepts-GH53354.cpp:19 +template +requires C1 and true +struct A {}; why not `&& true`!? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D136259/new/ https://reviews.llvm.org/D136259 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D136259: Fix crash in constraining partial specialization on nested template.
usaxena95 updated this revision to Diff 468925. usaxena95 added a comment. Added test. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D136259/new/ https://reviews.llvm.org/D136259 Files: clang/lib/Sema/SemaTemplateDeduction.cpp clang/test/SemaTemplate/concepts-GH53354.cpp Index: clang/test/SemaTemplate/concepts-GH53354.cpp === --- /dev/null +++ clang/test/SemaTemplate/concepts-GH53354.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -std=c++20 -verify %s +// expected-no-diagnostics + +template class> +struct S +{}; + +template +concept C1 = requires +{ + typename S; +}; + +template +requires C1 +struct A {}; + +template +requires C1 and true +struct A {}; \ No newline at end of file Index: clang/lib/Sema/SemaTemplateDeduction.cpp === --- clang/lib/Sema/SemaTemplateDeduction.cpp +++ clang/lib/Sema/SemaTemplateDeduction.cpp @@ -5804,10 +5804,10 @@ } bool TraverseTemplateName(TemplateName Template) { -if (auto *TTP = -dyn_cast(Template.getAsTemplateDecl())) - if (TTP->getDepth() == Depth) -Used[TTP->getIndex()] = true; +if (TemplateDecl *TD = Template.getAsTemplateDecl()) + if (auto *TTP = dyn_cast(TD)) +if (TTP->getDepth() == Depth) + Used[TTP->getIndex()] = true; RecursiveASTVisitor:: TraverseTemplateName(Template); return true; Index: clang/test/SemaTemplate/concepts-GH53354.cpp === --- /dev/null +++ clang/test/SemaTemplate/concepts-GH53354.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -std=c++20 -verify %s +// expected-no-diagnostics + +template class> +struct S +{}; + +template +concept C1 = requires +{ + typename S; +}; + +template +requires C1 +struct A {}; + +template +requires C1 and true +struct A {}; \ No newline at end of file Index: clang/lib/Sema/SemaTemplateDeduction.cpp === --- clang/lib/Sema/SemaTemplateDeduction.cpp +++ clang/lib/Sema/SemaTemplateDeduction.cpp @@ -5804,10 +5804,10 @@ } bool TraverseTemplateName(TemplateName Template) { -if (auto *TTP = -dyn_cast(Template.getAsTemplateDecl())) - if (TTP->getDepth() == Depth) -Used[TTP->getIndex()] = true; +if (TemplateDecl *TD = Template.getAsTemplateDecl()) + if (auto *TTP = dyn_cast(TD)) +if (TTP->getDepth() == Depth) + Used[TTP->getIndex()] = true; RecursiveASTVisitor:: TraverseTemplateName(Template); return true; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D136259: Fix crash in constraining partial specialization on nested template.
usaxena95 created this revision. Herald added a project: All. usaxena95 requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Fixes: https://github.com/llvm/llvm-project/issues/53354 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D136259 Files: clang/lib/Sema/SemaTemplateDeduction.cpp Index: clang/lib/Sema/SemaTemplateDeduction.cpp === --- clang/lib/Sema/SemaTemplateDeduction.cpp +++ clang/lib/Sema/SemaTemplateDeduction.cpp @@ -5804,10 +5804,10 @@ } bool TraverseTemplateName(TemplateName Template) { -if (auto *TTP = -dyn_cast(Template.getAsTemplateDecl())) - if (TTP->getDepth() == Depth) -Used[TTP->getIndex()] = true; +if (TemplateDecl *TD = Template.getAsTemplateDecl()) + if (auto *TTP = dyn_cast(TD)) +if (TTP->getDepth() == Depth) + Used[TTP->getIndex()] = true; RecursiveASTVisitor:: TraverseTemplateName(Template); return true; Index: clang/lib/Sema/SemaTemplateDeduction.cpp === --- clang/lib/Sema/SemaTemplateDeduction.cpp +++ clang/lib/Sema/SemaTemplateDeduction.cpp @@ -5804,10 +5804,10 @@ } bool TraverseTemplateName(TemplateName Template) { -if (auto *TTP = -dyn_cast(Template.getAsTemplateDecl())) - if (TTP->getDepth() == Depth) -Used[TTP->getIndex()] = true; +if (TemplateDecl *TD = Template.getAsTemplateDecl()) + if (auto *TTP = dyn_cast(TD)) +if (TTP->getDepth() == Depth) + Used[TTP->getIndex()] = true; RecursiveASTVisitor:: TraverseTemplateName(Template); return true; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits