Author: David Blaikie Date: 2020-04-05T16:31:30-07:00 New Revision: e9644e6f4f21e6b6177ef9085cdc9ed9f44b7783
URL: https://github.com/llvm/llvm-project/commit/e9644e6f4f21e6b6177ef9085cdc9ed9f44b7783 DIFF: https://github.com/llvm/llvm-project/commit/e9644e6f4f21e6b6177ef9085cdc9ed9f44b7783.diff LOG: DebugInfo: Fix default template parameter computation for dependent non-type template parameters This addresses the immediate bug, though in theory we could still produce a default parameter for the DWARF in this test case - but other cases will be definitely unachievable (you could have a default parameter that cannot be evaluated - so long as the user overrode it with another value rather than relying on that default) Added: Modified: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGenCXX/debug-info-template-parameter.cpp Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 6d3c2ad66cdc..5f05323f61ef 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -1816,7 +1816,8 @@ CGDebugInfo::CollectTemplateParams(const TemplateParameterList *TPList, if (TPList && CGM.getCodeGenOpts().DwarfVersion >= 5) if (auto *templateType = dyn_cast_or_null<NonTypeTemplateParmDecl>(TPList->getParam(i))) - if (templateType->hasDefaultArgument()) + if (templateType->hasDefaultArgument() && + !templateType->getDefaultArgument()->isValueDependent()) defaultParameter = llvm::APSInt::isSameValue( templateType->getDefaultArgument()->EvaluateKnownConstInt( CGM.getContext()), diff --git a/clang/test/CodeGenCXX/debug-info-template-parameter.cpp b/clang/test/CodeGenCXX/debug-info-template-parameter.cpp index c38c535d8b06..fee6dfe8b898 100644 --- a/clang/test/CodeGenCXX/debug-info-template-parameter.cpp +++ b/clang/test/CodeGenCXX/debug-info-template-parameter.cpp @@ -8,24 +8,24 @@ // CHECK: DILocalVariable(name: "f1", {{.*}}, type: ![[TEMPLATE_TYPE:[0-9]+]] // CHECK: [[TEMPLATE_TYPE]] = {{.*}}!DICompositeType({{.*}}, templateParams: ![[F1_TYPE:[0-9]+]] -// CHECK: [[F1_TYPE]] = !{![[FIRST:[0-9]+]], ![[SECOND:[0-9]+]], ![[THIRD:[0-9]+]]} +// CHECK: [[F1_TYPE]] = !{![[FIRST:[0-9]+]], ![[SECOND:[0-9]+]], ![[THIRD:[0-9]+]], ![[FORTH:[0-9]+]]} // CHECK: [[FIRST]] = !DITemplateTypeParameter(name: "T", type: !{{[0-9]*}}) // CHECK: [[SECOND]] = !DITemplateValueParameter(name: "i", type: !{{[0-9]*}}, value: i32 6) // CHECK: [[THIRD]] = !DITemplateValueParameter(name: "b", type: !{{[0-9]*}}, value: i8 0) // CHECK: DILocalVariable(name: "f2", {{.*}}, type: ![[TEMPLATE_TYPE:[0-9]+]] // CHECK: [[TEMPLATE_TYPE]] = {{.*}}!DICompositeType({{.*}}, templateParams: ![[F2_TYPE:[0-9]+]] -// CHECK: [[F2_TYPE]] = !{![[FIRST:[0-9]+]], ![[SECOND:[0-9]+]], ![[THIRD:[0-9]+]]} +// CHECK: [[F2_TYPE]] = !{![[FIRST:[0-9]+]], ![[SECOND:[0-9]+]], ![[THIRD:[0-9]+]], ![[FORTH:[0-9]+]]} // CHECK: [[FIRST]] = !DITemplateTypeParameter(name: "T", type: !{{[0-9]*}}, defaulted: true) // CHECK: [[SECOND]] = !DITemplateValueParameter(name: "i", type: !{{[0-9]*}}, defaulted: true, value: i32 3) // CHECK: [[THIRD]] = !DITemplateValueParameter(name: "b", type: !{{[0-9]*}}, defaulted: true, value: i8 1) -template <typename T = char, int i = 3, bool b = true> +template <typename T = char, int i = 3, bool b = true, int x = sizeof(T)> class foo { }; int main() { - foo<int, 6, false> f1; + foo<int, 6, false, 3> f1; foo<> f2; return 0; } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits