<div dir="ltr">Thanks all, indeed it seems that the scope is not mandatory for fields and other class members, the DINodeArray Elements seems to be the rule to follow.<br><br>As a side note, this implementation of DebugInfo based on dynamic MetaData structures and opaque construction is very hard to understand, read and debug.. 

<br>Each time you look at a DIXxx variable in the debugger, you just have opaque variables even with the natvis.. <br>That would be nice to be able to explore the whole DI hierarchy when exploring a DINode, for example : <br>-DICompositeType "class Foo<br>    - DISubprogram "method0"<br>    - DISubprogram "method1"<br>    - DIDerivedType "field0<br>To at least know if you are doing the right thing.  <br><br>For example I have another issue with template arguments I want to give to createClassType.<br>The parameter type for TemplateArgs is MDNode .. ? What should I do with that ? How can I understand what I need to give it except by exploring CGDebugInfo code ? (which does not use it btw)<br>This is not intuitive. <br>The documentation is just only repeating what the code already tells, without giving any hint on how to use the functions. <br>It's like "try your luck and prey it works as you imagined".<div>For template arguments I tried giving the class as the scope of a TemplateTypeParameter, I tried to create a MDTuple with my parameters and give it to the createClassType, nothing works.<br>I get out of ideas here. <br>In Clang it uses a "replaceArrays" somewhere to put template arguments after a code that does replacements everywhere. <br>It looks like Clang never uses createClassType but always create replaceable composite types (I will try this, but that would be <br>very bad news for the design that it works using replacements while not working with the straightforward way...)<br>And the replaceArrays takes a TemplateParameterArray, why not a MDNode like createClassType ? (or the other way) <br><br>I'm sorry If I'm a bit critical here, but it is very hard to work by "hoping it is what i should have done"... <br><br>Anyway, If someone can help me with this template parameter thing it would be very appreciated :))<br>Thank you !</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le jeu. 7 févr. 2019 à 17:43, <<a href="mailto:paul.robinson@sony.com">paul.robinson@sony.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="EN-US" style="overflow-wrap: break-word;">
<div class="gmail-m_-5948699724500079035WordSection1">
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Commentary in CGDebugInfo::CreateTypeDefinition says it first creates a forward declaration for the record, then adds the members to it using the forward declaration
 as the scope; then it does some sort of fixup. It looks like the fixup part is MDNode::replaceWithPermanent which is admittedly not a particularly smooth interface.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Adrian or David might be able to comment on that part.<u></u><u></u></span></p>
<p class="MsoNormal"><a name="m_-5948699724500079035__MailEndCompose"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">--paulr<u></u><u></u></span></a></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<div style="border-top:none;border-right:none;border-bottom:none;border-left:1.5pt solid blue;padding:0in 0in 0in 4pt">
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(181,196,223);padding:3pt 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span style="font-size:10pt;font-family:Tahoma,sans-serif"> llvm-dev [mailto:<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>]
<b>On Behalf Of </b>Adrian Prantl via llvm-dev<br>
<b>Sent:</b> Wednesday, February 06, 2019 1:26 PM<br>
<b>To:</b> David Blaikie<br>
<b>Cc:</b> Vivien Millet; llvm-dev<br>
<b>Subject:</b> Re: [llvm-dev] [DebugInfo][DIBuilder] Good way to pass arguments to createClassType/createMemberType<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">At least for generating DWARF the scope of of a composite type member should be irrelevant since it will always be nested inside its parent.<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">-- adrian<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><br>
<br>
<u></u><u></u></p>
<div>
<p class="MsoNormal">On Feb 6, 2019, at 10:24 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12pt">A good rough rule of thumb here is "what would/does Clang do?" & it looks (to me, on a very cursory glance) like Clang mostly passes the unit's DIFile as the scope parameter for a member - so perhaps it's just
 ignored? not sure.<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">On Tue, Feb 5, 2019 at 1:38 PM Vivien Millet via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in">
<div>
<p class="MsoNormal">Hi,<u></u><u></u></p>
<div>
<p class="MsoNormal">I'm trying to use DIBuilder to build my debug info and export it into a PDB, but I don't understand the way some DIBuilder method work.<br>
My question might have a straightforward answer but I don't see it ... (and I can't find any example code using these methods anywhere).<br>
Indeed createClassType takes an "Elements" argument, and createMemberType takes a "Scope" argument. Like the "who's first, egg or hen", I don't know If I need to create my members first using le compilation unit as the scope, put them in an array and give them
 to createClassType Elements parameter. Or forget the Elements parameter, call createClassType first then give it as "Scope" of createMemberType..<br>
Thanks !<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal">_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><u></u><u></u></p>
</blockquote>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div>

</blockquote></div>