[clang] db92719 - DebugInfo: Defaulted non-type template parameters of bool type

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 1 13:28:31 PDT 2020


On Wed, Apr 1, 2020 at 1:21 PM David Blaikie via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

>
> Author: David Blaikie
> Date: 2020-04-01T13:21:13-07:00
> New Revision: db92719c1d17f5052e7cd1309b0e1e92240f47be
>
> URL:
> https://github.com/llvm/llvm-project/commit/db92719c1d17f5052e7cd1309b0e1e92240f47be
> DIFF:
> https://github.com/llvm/llvm-project/commit/db92719c1d17f5052e7cd1309b0e1e92240f47be.diff
>
> LOG: DebugInfo: Defaulted non-type template parameters of bool type
>
> Caused an assertion due to mismatched bit widths - this seems like the
> right API to use for a possibly width-varying equality test. Though
> certainly open to some post-commit review feedback if there's a more
> suitable way to do this comparison/test.
>
> 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 49c57e9860a6..6d3c2ad66cdc 100644
> --- a/clang/lib/CodeGen/CGDebugInfo.cpp
> +++ b/clang/lib/CodeGen/CGDebugInfo.cpp
> @@ -1817,9 +1817,10 @@ CGDebugInfo::CollectTemplateParams(const
> TemplateParameterList *TPList,
>          if (auto *templateType =
>
>  dyn_cast_or_null<NonTypeTemplateParmDecl>(TPList->getParam(i)))
>            if (templateType->hasDefaultArgument())
> -            defaultParameter =
> +            defaultParameter = llvm::APSInt::isSameValue(
>                  templateType->getDefaultArgument()->EvaluateKnownConstInt(
> -                    CGM.getContext()) == TA.getAsIntegral();
> +                    CGM.getContext()),
> +                TA.getAsIntegral());
>

Hey Richard - is this the best way to do this? Are there other ways to test
if a default argument is the same as the actual template parameter we
could/should be doing here?


>
>        TemplateParams.push_back(DBuilder.createTemplateValueParameter(
>            TheCU, Name, TTy, defaultParameter,
>
> diff  --git a/clang/test/CodeGenCXX/debug-info-template-parameter.cpp
> b/clang/test/CodeGenCXX/debug-info-template-parameter.cpp
> index 95e7a187fe10..c38c535d8b06 100644
> --- a/clang/test/CodeGenCXX/debug-info-template-parameter.cpp
> +++ b/clang/test/CodeGenCXX/debug-info-template-parameter.cpp
> @@ -8,22 +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]+]]}
> +// CHECK: [[F1_TYPE]] = !{![[FIRST:[0-9]+]], ![[SECOND:[0-9]+]],
> ![[THIRD:[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]+]]}
> +// CHECK: [[F2_TYPE]] = !{![[FIRST:[0-9]+]], ![[SECOND:[0-9]+]],
> ![[THIRD:[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>
> +template <typename T = char, int i = 3, bool b = true>
>  class foo {
>  };
>
>  int main() {
> -  foo<int, 6> f1;
> +  foo<int, 6, false> f1;
>    foo<> f2;
>    return 0;
>  }
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200401/1881640a/attachment.html>


More information about the cfe-commits mailing list