<html><head></head><body class="ApplePlainTextBody" dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi David!<br><br>Slightly tangential, but this also reminds me that I eventually was going to send out a proposal for debug info for Modules/PCH. Having access to the serialized AST in its entirety would eliminate problems like this nicely. DWARF is extended by an external AST type DIE that is merely a USR-based index into the corresponding module file. Everything that is not explicitly referenced in the DWARF can still be found in the module/PCH and read via libclang...<br><br><br>On Mar 3, 2014, at 8:41 AM, David Blaikie <dblaikie@gmail.com> wrote:<br><br><blockquote type="cite">We have a few bugs like ( http://llvm.org/bugs/show_bug.cgi?id=19005 )<br>in debug info that all stem from the same basic problem:<br><br>A type that's not referenced by another debug entity (such as a<br>variable, parameter, function, etc) is not emitted in the debug info.<br><br>GCC, while not being wholely consistent at addressing this, does get<br>it 'more' right. I'd like Clang to be better at this as well, even if<br>we're not perfect.<br><br>The basic premise to implement this perfectly would be: If we're<br>emitting code for a function (or global variable initializer, etc) and<br>within that function a certain type is required to be complete, emit<br>the type (and include it in the "retained types list").<br><br>Does anyone have nice ideas on how we could realistically implement<br>that test (yeah, I'm mostly looking at Richard on this) or a rough<br>approximation that might get the 90% case?<br></blockquote><br>The idea would be for the fronted to register a record type as debug-info-retained whenever, e.g., it is calculating the record's memory layout (or similar)?<div><br></div><div>I guess this is really a question for the fronted p<br><blockquote type="cite"><br>And as a bonus it'd probably be good if we didn't do this for cases<br>where we already successfully emit the type (eg: if it's required to<br>be complete because there's a variable of that type we'd rather not<br>add that type to the retained types list needlessly... but there are<br>some wrinkles there)<br><br>Some examples:<br><br>Neither GCC nor Clang emit 'foo' here:<br><br>struct foo {<br> foo();<br> int i;<br>};<br><br>void func(int);<br><br>void func() {<br> func(foo().i + 1);<br>}<br><br>int main() {<br>}<br><br>but GCC does emit it if the foo ctor called is not the default (<br>declare 'foo(int)' and use 'foo(3).i' instead of 'foo().i').<br><br>And the previously linked bug amounts to "func(((foo*)v)->i + 1);"<br>(for some "void* v") - in which GCC does emit 'foo' and Clang does<br>not.<br><br>So, yes - nothing terribly consistent. It would nice to do better<br>(better than we are, maybe even better than GCC, or at least more<br>consistent).<br></blockquote><br></div></body></html>