[PATCH] D30082: Fix assertion when generating debug information for deduced template specialization types.
This revision was automatically updated to reflect the committed changes. Closed by commit rL295794: Fix assertion failure when generating debug information for a variable (authored by rsmith). Changed prior to commit: https://reviews.llvm.org/D30082?vs=88943=89300#toc Repository: rL LLVM https://reviews.llvm.org/D30082 Files: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/test/CodeGenCXX/debug-info-template-deduction-guide.cpp Index: cfe/trunk/test/CodeGenCXX/debug-info-template-deduction-guide.cpp === --- cfe/trunk/test/CodeGenCXX/debug-info-template-deduction-guide.cpp +++ cfe/trunk/test/CodeGenCXX/debug-info-template-deduction-guide.cpp @@ -0,0 +1,17 @@ +// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - -std=c++1z | FileCheck %s + +// Verify that we don't crash when emitting debug information for objects +// created from a deduced template specialization. + +template +struct S { + S(T) {} +}; + +// CHECK: !DIGlobalVariable(name: "s1" +// CHECK-SAME: type: [[TYPE_NUM:![0-9]+]] +// CHECK: !DIGlobalVariable(name: "s2" +// CHECK-SAME: type: [[TYPE_NUM]] +// CHECK: [[TYPE_NUM]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", +S s1(42); +S s2(42); Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp === --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp @@ -2475,8 +2475,9 @@ case Type::SubstTemplateTypeParm: T = cast(T)->getReplacementType(); break; -case Type::Auto: { - QualType DT = cast(T)->getDeducedType(); +case Type::Auto: +case Type::DeducedTemplateSpecialization: { + QualType DT = cast(T)->getDeducedType(); assert(!DT.isNull() && "Undeduced types shouldn't reach here."); T = DT; break; Index: cfe/trunk/test/CodeGenCXX/debug-info-template-deduction-guide.cpp === --- cfe/trunk/test/CodeGenCXX/debug-info-template-deduction-guide.cpp +++ cfe/trunk/test/CodeGenCXX/debug-info-template-deduction-guide.cpp @@ -0,0 +1,17 @@ +// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - -std=c++1z | FileCheck %s + +// Verify that we don't crash when emitting debug information for objects +// created from a deduced template specialization. + +template +struct S { + S(T) {} +}; + +// CHECK: !DIGlobalVariable(name: "s1" +// CHECK-SAME: type: [[TYPE_NUM:![0-9]+]] +// CHECK: !DIGlobalVariable(name: "s2" +// CHECK-SAME: type: [[TYPE_NUM]] +// CHECK: [[TYPE_NUM]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", +S s1(42); +S s2(42); Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp === --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp @@ -2475,8 +2475,9 @@ case Type::SubstTemplateTypeParm: T = cast(T)->getReplacementType(); break; -case Type::Auto: { - QualType DT = cast(T)->getDeducedType(); +case Type::Auto: +case Type::DeducedTemplateSpecialization: { + QualType DT = cast(T)->getDeducedType(); assert(!DT.isNull() && "Undeduced types shouldn't reach here."); T = DT; break; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30082: Fix assertion when generating debug information for deduced template specialization types.
rsmith accepted this revision. rsmith added a comment. This revision is now accepted and ready to land. LGTM, thanks! https://reviews.llvm.org/D30082 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30082: Fix assertion when generating debug information for deduced template specialization types.
EricWF updated this revision to Diff 88943. EricWF marked 2 inline comments as done. EricWF added a comment. Address @rsmith's review comments. https://reviews.llvm.org/D30082 Files: lib/CodeGen/CGDebugInfo.cpp test/CodeGenCXX/debug-info-template-deduction-guide.cpp Index: test/CodeGenCXX/debug-info-template-deduction-guide.cpp === --- /dev/null +++ test/CodeGenCXX/debug-info-template-deduction-guide.cpp @@ -0,0 +1,17 @@ +// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - -std=c++1z | FileCheck %s + +// Verify that we don't crash when emitting debug information for objects +// created from a deduced template specialization. + +template +struct S { + S(T) {} +}; + +// CHECK: !DIGlobalVariable(name: "s1" +// CHECK-SAME: type: [[TYPE_NUM:![0-9]+]] +// CHECK: !DIGlobalVariable(name: "s2" +// CHECK-SAME: type: [[TYPE_NUM]] +// CHECK: [[TYPE_NUM]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", +S s1(42); +S s2(42); Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -2475,8 +2475,9 @@ case Type::SubstTemplateTypeParm: T = cast(T)->getReplacementType(); break; -case Type::Auto: { - QualType DT = cast(T)->getDeducedType(); +case Type::Auto: +case Type::DeducedTemplateSpecialization: { + QualType DT = cast(T)->getDeducedType(); assert(!DT.isNull() && "Undeduced types shouldn't reach here."); T = DT; break; Index: test/CodeGenCXX/debug-info-template-deduction-guide.cpp === --- /dev/null +++ test/CodeGenCXX/debug-info-template-deduction-guide.cpp @@ -0,0 +1,17 @@ +// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - -std=c++1z | FileCheck %s + +// Verify that we don't crash when emitting debug information for objects +// created from a deduced template specialization. + +template +struct S { + S(T) {} +}; + +// CHECK: !DIGlobalVariable(name: "s1" +// CHECK-SAME: type: [[TYPE_NUM:![0-9]+]] +// CHECK: !DIGlobalVariable(name: "s2" +// CHECK-SAME: type: [[TYPE_NUM]] +// CHECK: [[TYPE_NUM]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", +S s1(42); +S s2(42); Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -2475,8 +2475,9 @@ case Type::SubstTemplateTypeParm: T = cast(T)->getReplacementType(); break; -case Type::Auto: { - QualType DT = cast(T)->getDeducedType(); +case Type::Auto: +case Type::DeducedTemplateSpecialization: { + QualType DT = cast(T)->getDeducedType(); assert(!DT.isNull() && "Undeduced types shouldn't reach here."); T = DT; break; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30082: Fix assertion when generating debug information for deduced template specialization types.
rsmith added inline comments. Comment at: lib/CodeGen/CGDebugInfo.cpp:2478 break; +case Type::DeducedTemplateSpecialization: { + QualType DT = cast(T)->getDeducedType(); EricWF wrote: > I'll put this in alphabetical order before committing. Reuse the Type::Auto case here rather than duplicating it. (You'll need to change its AutoType to the DeducedType common base class.) https://reviews.llvm.org/D30082 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30082: Fix assertion when generating debug information for deduced template specialization types.
EricWF added inline comments. Comment at: lib/CodeGen/CGDebugInfo.cpp:2478 break; +case Type::DeducedTemplateSpecialization: { + QualType DT = cast(T)->getDeducedType(); I'll put this in alphabetical order before committing. https://reviews.llvm.org/D30082 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30082: Fix assertion when generating debug information for deduced template specialization types.
EricWF updated this revision to Diff 88861. EricWF marked an inline comment as done. EricWF added a comment. Address @majnemer's comments. https://reviews.llvm.org/D30082 Files: lib/CodeGen/CGDebugInfo.cpp test/CodeGenCXX/debug-info-template-deduction-guide.cpp Index: test/CodeGenCXX/debug-info-template-deduction-guide.cpp === --- /dev/null +++ test/CodeGenCXX/debug-info-template-deduction-guide.cpp @@ -0,0 +1,17 @@ +// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - -std=c++1z | FileCheck %s + +// Verify that we don't crash when emitting debug information for objects +// created from a deduced template specialization. + +template +struct S { + S(T) {} +}; + +// CHECK: !DIGlobalVariable(name: "s1" +// CHECK-SAME: type: [[TYPE_NUM:![0-9]+]] +// CHECK: !DIGlobalVariable(name: "s2" +// CHECK-SAME: type: [[TYPE_NUM]] +// CHECK: [[TYPE_NUM]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", +S s1(42); +S s2(42); Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -2475,6 +2475,12 @@ case Type::SubstTemplateTypeParm: T = cast(T)->getReplacementType(); break; +case Type::DeducedTemplateSpecialization: { + QualType DT = cast(T)->getDeducedType(); + assert(!DT.isNull() && "Undeduced types shouldn't reach here."); + T = DT; + break; +} case Type::Auto: { QualType DT = cast(T)->getDeducedType(); assert(!DT.isNull() && "Undeduced types shouldn't reach here."); Index: test/CodeGenCXX/debug-info-template-deduction-guide.cpp === --- /dev/null +++ test/CodeGenCXX/debug-info-template-deduction-guide.cpp @@ -0,0 +1,17 @@ +// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - -std=c++1z | FileCheck %s + +// Verify that we don't crash when emitting debug information for objects +// created from a deduced template specialization. + +template +struct S { + S(T) {} +}; + +// CHECK: !DIGlobalVariable(name: "s1" +// CHECK-SAME: type: [[TYPE_NUM:![0-9]+]] +// CHECK: !DIGlobalVariable(name: "s2" +// CHECK-SAME: type: [[TYPE_NUM]] +// CHECK: [[TYPE_NUM]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", +S s1(42); +S s2(42); Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -2475,6 +2475,12 @@ case Type::SubstTemplateTypeParm: T = cast(T)->getReplacementType(); break; +case Type::DeducedTemplateSpecialization: { + QualType DT = cast(T)->getDeducedType(); + assert(!DT.isNull() && "Undeduced types shouldn't reach here."); + T = DT; + break; +} case Type::Auto: { QualType DT = cast(T)->getDeducedType(); assert(!DT.isNull() && "Undeduced types shouldn't reach here."); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30082: Fix assertion when generating debug information for deduced template specialization types.
EricWF marked an inline comment as done. EricWF added inline comments. Comment at: lib/CodeGen/CGDebugInfo.cpp:2479 +case Type::DeducedTemplateSpecialization: { + QualType DT = dyn_cast(T)->getDeducedType(); + assert(!DT.isNull() && "Undeduced types shouldn't reach here."); majnemer wrote: > You are unconditionally dereferencing a dyn_cast, this seems bad. Is T > sometimes not a DeducedType or should the dyn_cast be a cast? Woops that should have been a `cast` instead of a `dyn_cast`. `T` should always be `DeducedType` (See AstContext.cpp:1879 for an example use of `cast(...)` ). https://reviews.llvm.org/D30082 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30082: Fix assertion when generating debug information for deduced template specialization types.
majnemer added inline comments. Comment at: lib/CodeGen/CGDebugInfo.cpp:2479 +case Type::DeducedTemplateSpecialization: { + QualType DT = dyn_cast(T)->getDeducedType(); + assert(!DT.isNull() && "Undeduced types shouldn't reach here."); You are unconditionally dereferencing a dyn_cast, this seems bad. Is T sometimes not a DeducedType or should the dyn_cast be a cast? https://reviews.llvm.org/D30082 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30082: Fix assertion when generating debug information for deduced template specialization types.
EricWF updated this revision to Diff 88859. EricWF added a comment. Remove unintentional changes. https://reviews.llvm.org/D30082 Files: lib/CodeGen/CGDebugInfo.cpp test/CodeGenCXX/debug-info-template-deduction-guide.cpp Index: test/CodeGenCXX/debug-info-template-deduction-guide.cpp === --- /dev/null +++ test/CodeGenCXX/debug-info-template-deduction-guide.cpp @@ -0,0 +1,17 @@ +// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - -std=c++1z | FileCheck %s + +// Verify that we don't crash when emitting debug information for objects +// created from a deduced template specialization. + +template +struct S { + S(T) {} +}; + +// CHECK: !DIGlobalVariable(name: "s1" +// CHECK-SAME: type: [[TYPE_NUM:![0-9]+]] +// CHECK: !DIGlobalVariable(name: "s2" +// CHECK-SAME: type: [[TYPE_NUM]] +// CHECK: [[TYPE_NUM]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", +S s1(42); +S s2(42); Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -2475,6 +2475,12 @@ case Type::SubstTemplateTypeParm: T = cast(T)->getReplacementType(); break; +case Type::DeducedTemplateSpecialization: { + QualType DT = dyn_cast(T)->getDeducedType(); + assert(!DT.isNull() && "Undeduced types shouldn't reach here."); + T = DT; + break; +} case Type::Auto: { QualType DT = cast(T)->getDeducedType(); assert(!DT.isNull() && "Undeduced types shouldn't reach here."); Index: test/CodeGenCXX/debug-info-template-deduction-guide.cpp === --- /dev/null +++ test/CodeGenCXX/debug-info-template-deduction-guide.cpp @@ -0,0 +1,17 @@ +// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - -std=c++1z | FileCheck %s + +// Verify that we don't crash when emitting debug information for objects +// created from a deduced template specialization. + +template +struct S { + S(T) {} +}; + +// CHECK: !DIGlobalVariable(name: "s1" +// CHECK-SAME: type: [[TYPE_NUM:![0-9]+]] +// CHECK: !DIGlobalVariable(name: "s2" +// CHECK-SAME: type: [[TYPE_NUM]] +// CHECK: [[TYPE_NUM]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", +S s1(42); +S s2(42); Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -2475,6 +2475,12 @@ case Type::SubstTemplateTypeParm: T = cast(T)->getReplacementType(); break; +case Type::DeducedTemplateSpecialization: { + QualType DT = dyn_cast(T)->getDeducedType(); + assert(!DT.isNull() && "Undeduced types shouldn't reach here."); + T = DT; + break; +} case Type::Auto: { QualType DT = cast(T)->getDeducedType(); assert(!DT.isNull() && "Undeduced types shouldn't reach here."); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30082: Fix assertion when generating debug information for deduced template specialization types.
EricWF created this revision. Herald added a subscriber: aprantl. Currently the following code hits an `llvm_unreachable` in `CGDebugInfo::CreateTypeNode` because `DeducedTemplateSpecialization` isn't handled. // clang++ -std=c++1z -g test.cpp template struct S { S(T) {} }; S s(42); This patch attempts to fix the handling of `DeducedTemplateSpecialization` as to correctly emit debug information. I've also attempted to write a test checking the emission of the debug information, but IDK if it's testing for the right output. https://reviews.llvm.org/D30082 Files: lib/CodeGen/CGDebugInfo.cpp test/CodeGenCXX/debug-info-template-deduction-guide.cpp Index: test/CodeGenCXX/debug-info-template-deduction-guide.cpp === --- /dev/null +++ test/CodeGenCXX/debug-info-template-deduction-guide.cpp @@ -0,0 +1,17 @@ +// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - -std=c++1z | FileCheck %s + +// Verify that we don't crash when emitting debug information for objects +// created from a deduced template specialization. + +template +struct S { + S(T) {} +}; + +// CHECK: !DIGlobalVariable(name: "s1" +// CHECK-SAME: type: [[TYPE_NUM:![0-9]+]] +// CHECK: !DIGlobalVariable(name: "s2" +// CHECK-SAME: type: [[TYPE_NUM]] +// CHECK: [[TYPE_NUM]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", +S s1(42); +S s2(42); Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -2475,6 +2475,12 @@ case Type::SubstTemplateTypeParm: T = cast(T)->getReplacementType(); break; +case Type::DeducedTemplateSpecialization: { + QualType DT = dyn_cast(T)->getDeducedType(); + assert(!DT.isNull() && "Undeduced types shouldn't reach here."); + T = DT; + break; +} case Type::Auto: { QualType DT = cast(T)->getDeducedType(); assert(!DT.isNull() && "Undeduced types shouldn't reach here."); @@ -2638,11 +2644,12 @@ case Type::TemplateSpecialization: return CreateType(cast(Ty), Unit); + case Type::DeducedTemplateSpecialization: +assert(isa(Ty)); case Type::Auto: case Type::Attributed: case Type::Adjusted: case Type::Decayed: - case Type::DeducedTemplateSpecialization: case Type::Elaborated: case Type::Paren: case Type::SubstTemplateTypeParm: Index: test/CodeGenCXX/debug-info-template-deduction-guide.cpp === --- /dev/null +++ test/CodeGenCXX/debug-info-template-deduction-guide.cpp @@ -0,0 +1,17 @@ +// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - -std=c++1z | FileCheck %s + +// Verify that we don't crash when emitting debug information for objects +// created from a deduced template specialization. + +template +struct S { + S(T) {} +}; + +// CHECK: !DIGlobalVariable(name: "s1" +// CHECK-SAME: type: [[TYPE_NUM:![0-9]+]] +// CHECK: !DIGlobalVariable(name: "s2" +// CHECK-SAME: type: [[TYPE_NUM]] +// CHECK: [[TYPE_NUM]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", +S s1(42); +S s2(42); Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -2475,6 +2475,12 @@ case Type::SubstTemplateTypeParm: T = cast(T)->getReplacementType(); break; +case Type::DeducedTemplateSpecialization: { + QualType DT = dyn_cast(T)->getDeducedType(); + assert(!DT.isNull() && "Undeduced types shouldn't reach here."); + T = DT; + break; +} case Type::Auto: { QualType DT = cast(T)->getDeducedType(); assert(!DT.isNull() && "Undeduced types shouldn't reach here."); @@ -2638,11 +2644,12 @@ case Type::TemplateSpecialization: return CreateType(cast(Ty), Unit); + case Type::DeducedTemplateSpecialization: +assert(isa(Ty)); case Type::Auto: case Type::Attributed: case Type::Adjusted: case Type::Decayed: - case Type::DeducedTemplateSpecialization: case Type::Elaborated: case Type::Paren: case Type::SubstTemplateTypeParm: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits