Look at the example I gave in my updated patch.  Just because it knows it's forward decl doesn't mean a complete decl won't show up *later*<br><div class="gmail_quote"><div dir="ltr">On Fri, Aug 25, 2017 at 6:06 PM Reid Kleckner via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">rnk added inline comments.<br>
<br>
<br>
================<br>
Comment at: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:2215<br>
+  // decl.<br>
+  TypeIndex TI = getTypeIndex(T);<br>
+  TypeIndex CTI = getCompleteTypeIndex(T);<br>
----------------<br>
zturner wrote:<br>
> rnk wrote:<br>
> > You should be able to dyn_cast to DICompositeType and call ->isForwardDecl(). Generally speaking, when translating one representation to another, it's better to look at the input and not the output whenever possible.<br>
> ><br>
> > Actually, is there any reason you can't do that during addToUdts? What does the `TI == CTI` comparision achieve?<br>
> We want to emit a UDT if:<br>
><br>
> 1. This is an enum/struct/union //that has a complete decl//<br>
> 2. This is a simple type.<br>
><br>
> If we just say `return !T->isForwardDecl();` this doesn't handle the case where `T` is a forward decl but a complete decl exists that we could remap to.<br>
><br>
> Also, for typedefs, `addToUdts(Ty)` can happen before we know if there will ever be a complete decl for `Ty` so this can't happen until the end.<br>
Re: typedefs, that's what I'm getting at. We don't have to wait to the end, because we should have the DICompositeType, and it already knows if it's complete or forward.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D37162" rel="noreferrer" target="_blank">https://reviews.llvm.org/D37162</a><br>
<br>
<br>
<br>
</blockquote></div>