<div dir="ltr"><div dir="ltr">On Wed, Sep 15, 2021 at 10:11 AM <<a href="mailto:paul.robinson@sony.com">paul.robinson@sony.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Nice to see this work coming to fruition.<br></blockquote><div><br></div><div>Yeah, this is fallout/cleanup for the "rebuild pretty names from template parameter DIEs" - I have a bunch of work locally that manages to round-trip names identically for all of clang, which is pretty good. A few types of names are flagged in the frontend as unrebuildable, so they get the full name - operator overloads (owing to potential ambiguity between a conversion operator that converts to a template specialization, and a conversion operator to a non-template type where the conversion operator itself is a template - and atomic integer types, which we currently don't have any DWARF structural representation of them being atomic, so far as I can tell)<br><br>I'll be peeling some more formatting improvements/fixes off that can be tested with the normal type printing work we have in llvm-dwarfdump, and then eventually the full name rebuilding pieces.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Comment on a comment inline.<br>
--paulr<br>
<br>
> -----Original Message-----<br>
> From: cfe-commits <<a href="mailto:cfe-commits-bounces@lists.llvm.org" target="_blank">cfe-commits-bounces@lists.llvm.org</a>> On Behalf Of David<br>
> Blaikie via cfe-commits<br>
> Sent: Tuesday, September 14, 2021 3:41 AM<br>
> To: <a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
> Subject: [clang] e4b9f5e - DebugInfo: Add support for template parameters<br>
> with reference qualifiers<br>
> <br>
> <br>
> Author: David Blaikie<br>
> Date: 2021-09-14T00:39:47-07:00<br>
> New Revision: e4b9f5e851d1fe0ba93cbb11b2ed4558602c379e<br>
> <br>
> URL: <a href="https://urldefense.com/v3/__https://github.com/llvm/llvm-" rel="noreferrer" target="_blank">https://urldefense.com/v3/__https://github.com/llvm/llvm-</a><br>
> project/commit/e4b9f5e851d1fe0ba93cbb11b2ed4558602c379e__;!!JmoZiZGBv3RvKR<br>
> Sx!pPDWW11rGokficZF20VnsBpjjCjLLhat-SnLoi9Iun-i_taCUiQMW_3RbXPXB8CHMg$<br>
> DIFF: <a href="https://urldefense.com/v3/__https://github.com/llvm/llvm-" rel="noreferrer" target="_blank">https://urldefense.com/v3/__https://github.com/llvm/llvm-</a><br>
> project/commit/e4b9f5e851d1fe0ba93cbb11b2ed4558602c379e.diff__;!!JmoZiZGBv<br>
> 3RvKRSx!pPDWW11rGokficZF20VnsBpjjCjLLhat-SnLoi9Iun-<br>
> i_taCUiQMW_3RbXOfYKwRDQ$<br>
> <br>
> LOG: DebugInfo: Add support for template parameters with reference<br>
> qualifiers<br>
> <br>
> Followon from the previous commit supporting cvr qualifiers.<br>
> <br>
> Added:<br>
> <br>
> <br>
> Modified:<br>
>     clang/lib/CodeGen/CGDebugInfo.cpp<br>
>     clang/test/CodeGenCXX/debug-info-template.cpp<br>
> <br>
> Removed:<br>
> <br>
> <br>
> <br>
> ##########################################################################<br>
> ######<br>
> diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp<br>
> b/clang/lib/CodeGen/CGDebugInfo.cpp<br>
> index b7a6cd4fdf84..e4dc3121a10f 100644<br>
> --- a/clang/lib/CodeGen/CGDebugInfo.cpp<br>
> +++ b/clang/lib/CodeGen/CGDebugInfo.cpp<br>
> @@ -1338,6 +1338,15 @@ static unsigned getDwarfCC(CallingConv CC) {<br>
>    return 0;<br>
>  }<br>
> <br>
> +static llvm::DINode::DIFlags getRefFlags(const FunctionProtoType *Func) {<br>
> +  llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;<br>
> +  if (Func->getExtProtoInfo().RefQualifier == RQ_LValue)<br>
> +    Flags |= llvm::DINode::FlagLValueReference;<br>
> +  if (Func->getExtProtoInfo().RefQualifier == RQ_RValue)<br>
> +    Flags |= llvm::DINode::FlagRValueReference;<br>
> +  return Flags;<br>
> +}<br>
> +<br>
>  llvm::DIType *CGDebugInfo::CreateType(const FunctionType *Ty,<br>
>                                        llvm::DIFile *Unit) {<br>
>    const auto *FPT = dyn_cast<FunctionProtoType>(Ty);<br>
> @@ -1353,11 +1362,13 @@ llvm::DIType *CGDebugInfo::CreateType(const<br>
> FunctionType *Ty,<br>
>    // Add the result type at least.<br>
>    EltTys.push_back(getOrCreateType(Ty->getReturnType(), Unit));<br>
> <br>
> +  llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;<br>
>    // Set up remainder of arguments if there is a prototype.<br>
>    // otherwise emit it as a variadic function.<br>
>    if (!FPT)<br>
>      EltTys.push_back(DBuilder.createUnspecifiedParameter());<br>
>    else {<br>
> +    Flags = getRefFlags(FPT);<br>
>      for (const QualType &ParamType : FPT->param_types())<br>
>        EltTys.push_back(getOrCreateType(ParamType, Unit));<br>
>      if (FPT->isVariadic())<br>
> @@ -1365,7 +1376,7 @@ llvm::DIType *CGDebugInfo::CreateType(const<br>
> FunctionType *Ty,<br>
>    }<br>
> <br>
>    llvm::DITypeRefArray EltTypeArray =<br>
> DBuilder.getOrCreateTypeArray(EltTys);<br>
> -  llvm::DIType *F = DBuilder.createSubroutineType(EltTypeArray,<br>
> llvm::DINode::FlagZero,<br>
> +  llvm::DIType *F = DBuilder.createSubroutineType(EltTypeArray, Flags,<br>
>                                         getDwarfCC(Ty->getCallConv()));<br>
>    return F;<br>
>  }<br>
> @@ -1640,15 +1651,17 @@<br>
> CGDebugInfo::getOrCreateInstanceMethodType(QualType ThisPtr,<br>
>    Qc.removeUnaligned();<br>
>    // Keep the removed qualifiers in sync with<br>
>    // CreateQualifiedType(const FunctionPrototype*, DIFile *Unit)<br>
> +  // on a 'real' member function type, these qualifiers are carried on<br>
> the type<br>
> +  // of the first parameter, not as separate DW_TAG_const_type (etc)<br>
> decorator<br>
> +  // tags around them. (but in the raw function types with qualifiers,<br>
> they have<br>
> +  // to use wrapper types)<br>
<br>
Please use proper capitalization and punctuation in comments.<br>
s/on/On/, s/(but/(But/, s/types)/types.)/<br>
<br></blockquote><div><br>Oh, sure - done in 





<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(170,171,37)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">8264846c0ef847adeacca9b8fe0f867a8a378c5e</span></p> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> <br>
>    // Add "this" pointer.<br>
> -  llvm::DITypeRefArray Args(<br>
> -      cast<llvm::DISubroutineType>(<br>
> -          getOrCreateType(<br>
> -              CGM.getContext().getFunctionType(Func->getReturnType(),<br>
> -                                               Func->getParamTypes(),<br>
> EPI),<br>
> -              Unit))<br>
> -          ->getTypeArray());<br>
> +  const auto *OriginalFunc = cast<llvm::DISubroutineType>(<br>
> +      getOrCreateType(CGM.getContext().getFunctionType(<br>
> +                          Func->getReturnType(), Func->getParamTypes(),<br>
> EPI),<br>
> +                      Unit));<br>
> +  llvm::DITypeRefArray Args = OriginalFunc->getTypeArray();<br>
>    assert(Args.size() && "Invalid number of arguments!");<br>
> <br>
>    SmallVector<llvm::Metadata *, 16> Elts;<br>
> @@ -1690,13 +1703,7 @@ CGDebugInfo::getOrCreateInstanceMethodType(QualType<br>
> ThisPtr,<br>
> <br>
>    llvm::DITypeRefArray EltTypeArray =<br>
> DBuilder.getOrCreateTypeArray(Elts);<br>
> <br>
> -  llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;<br>
> -  if (Func->getExtProtoInfo().RefQualifier == RQ_LValue)<br>
> -    Flags |= llvm::DINode::FlagLValueReference;<br>
> -  if (Func->getExtProtoInfo().RefQualifier == RQ_RValue)<br>
> -    Flags |= llvm::DINode::FlagRValueReference;<br>
> -<br>
> -  return DBuilder.createSubroutineType(EltTypeArray, Flags,<br>
> +  return DBuilder.createSubroutineType(EltTypeArray, OriginalFunc-<br>
> >getFlags(),<br>
>                                         getDwarfCC(Func->getCallConv()));<br>
>  }<br>
> <br>
> <br>
> diff  --git a/clang/test/CodeGenCXX/debug-info-template.cpp<br>
> b/clang/test/CodeGenCXX/debug-info-template.cpp<br>
> index 0abb669b6535..510c82a5074f 100644<br>
> --- a/clang/test/CodeGenCXX/debug-info-template.cpp<br>
> +++ b/clang/test/CodeGenCXX/debug-info-template.cpp<br>
> @@ -218,13 +218,13 @@ template void f1<>();<br>
> <br>
>  namespace RawFuncQual {<br>
>  struct t1; // use this to ensure the type parameter doesn't shift due to<br>
> other test cases in this file<br>
> -template<typename T1, typename T2><br>
> +template<typename T1, typename T2, typename T3, typename T4><br>
>  void f1() { }<br>
> -template void f1<t1 () volatile, t1 () const volatile>();<br>
> -// CHECK: !DISubprogram(name: "f1<RawFuncQual::t1 () volatile,<br>
> RawFuncQual::t1 () const volatile>",<br>
> +template void f1<t1 () volatile, t1 () const volatile, t1 () &, t1 ()<br>
> &&>();<br>
> +// CHECK: !DISubprogram(name: "f1<RawFuncQual::t1 () volatile,<br>
> RawFuncQual::t1 () const volatile, RawFuncQual::t1 () &, RawFuncQual::t1<br>
> () &&>",<br>
>  // CHECK-SAME: templateParams: ![[RAW_FUNC_QUAL_ARGS:[0-9]*]],<br>
> <br>
> -// CHECK: ![[RAW_FUNC_QUAL_ARGS]] = !{![[RAW_FUNC_QUAL_T1:[0-9]*]],<br>
> ![[RAW_FUNC_QUAL_T2:[0-9]*]]}<br>
> +// CHECK: ![[RAW_FUNC_QUAL_ARGS]] = !{![[RAW_FUNC_QUAL_T1:[0-9]*]],<br>
> ![[RAW_FUNC_QUAL_T2:[0-9]*]], ![[RAW_FUNC_QUAL_T3:[0-9]*]],<br>
> ![[RAW_FUNC_QUAL_T4:[0-9]*]]}<br>
>  // CHECK: ![[RAW_FUNC_QUAL_T1]] = !DITemplateTypeParameter(name: "T1",<br>
> type: ![[RAW_FUNC_QUAL_VOL:[0-9]*]])<br>
>  // CHECK: ![[RAW_FUNC_QUAL_VOL]] = !DIDerivedType(tag:<br>
> DW_TAG_volatile_type, baseType: ![[RAW_FUNC_QUAL_TYPE:[0-9]*]])<br>
>  // CHECK: ![[RAW_FUNC_QUAL_TYPE]] = !DISubroutineType(types:<br>
> ![[RAW_FUNC_QUAL_LIST:[0-9]*]]<br>
> @@ -232,5 +232,9 @@ template void f1<t1 () volatile, t1 () const<br>
> volatile>();<br>
>  // CHECK: ![[RAW_FUNC_QUAL_STRUCT]] = !DICompositeType(tag:<br>
> DW_TAG_structure_type, name: "t1"<br>
>  // CHECK: ![[RAW_FUNC_QUAL_T2]] = !DITemplateTypeParameter(name: "T2",<br>
> type: ![[RAW_FUNC_QUAL_CNST:[0-9]*]])<br>
>  // CHECK: ![[RAW_FUNC_QUAL_CNST]] = !DIDerivedType(tag:<br>
> DW_TAG_const_type, baseType: ![[RAW_FUNC_QUAL_TYPE:[0-9]*]])<br>
> +// CHECK: ![[RAW_FUNC_QUAL_T3]] = !DITemplateTypeParameter(name: "T3",<br>
> type: ![[RAW_FUNC_QUAL_REF:[0-9]*]])<br>
> +// CHECK: ![[RAW_FUNC_QUAL_REF]] = !DISubroutineType(flags:<br>
> DIFlagLValueReference, types: ![[RAW_FUNC_QUAL_LIST]])<br>
> +// CHECK: ![[RAW_FUNC_QUAL_T4]] = !DITemplateTypeParameter(name: "T4",<br>
> type: ![[RAW_FUNC_QUAL_REF_REF:[0-9]*]])<br>
> +// CHECK: ![[RAW_FUNC_QUAL_REF_REF]] = !DISubroutineType(flags:<br>
> DIFlagRValueReference, types: ![[RAW_FUNC_QUAL_LIST]])<br>
> <br>
>  } // namespace RawFuncQual<br>
> <br>
> <br>
> <br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
> <a href="https://urldefense.com/v3/__https://lists.llvm.org/cgi-" rel="noreferrer" target="_blank">https://urldefense.com/v3/__https://lists.llvm.org/cgi-</a><br>
> bin/mailman/listinfo/cfe-<br>
> commits__;!!JmoZiZGBv3RvKRSx!pPDWW11rGokficZF20VnsBpjjCjLLhat-SnLoi9Iun-<br>
> i_taCUiQMW_3RbXOKUGruLQ$<br>
</blockquote></div></div>