<div dir="ltr">Looks like this test could be a bit simpler:<br><br>struct foo;<div>foo *f; // produces a forward decl<br>struct foo {<br>  virtual ~foo();<br>};<br>foo f; // requires the type to be complete<br><br>A cursory glance looks like this reproduces the issue, but I may've missed something.<br><br>Also the bracing in the new condition you added is inconsistent with the existing bracing - could you fix that? (add braces to the middle if, following the "any block more than one line should have braces", or remove them from the outer one you added (following the "any block of a single statement should omit braces"))<br><br>(idle thought: It'd be good to make the code common between the first time a type is encountered, and the later callbacks when the type is completed, required to be complete, vtable is emitted, etc - the inconsistency here (& it's spread out through several functions: complete[Required]Type, shouldOmitDefinition, isDefinedInClangModule, etc) is a bit problematic/error prone)</div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Sep 9, 2016 at 10:12 AM Reid Kleckner via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rnk<br class="gmail_msg">
Date: Fri Sep  9 12:03:53 2016<br class="gmail_msg">
New Revision: 281057<br class="gmail_msg">
<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=281057&view=rev" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project?rev=281057&view=rev</a><br class="gmail_msg">
Log:<br class="gmail_msg">
[DebugInfo] Ensure complete type is emitted with -fstandalone-debug<br class="gmail_msg">
<br class="gmail_msg">
The logic for upgrading a class from a forward decl to a complete type<br class="gmail_msg">
was not checking the debug info emission level before applying the<br class="gmail_msg">
vtable optimization. This meant we ended up without debug info for a<br class="gmail_msg">
class which was required to be complete. I noticed it because it<br class="gmail_msg">
triggered an assertion during CodeView emission, but that's a separate<br class="gmail_msg">
issue.<br class="gmail_msg">
<br class="gmail_msg">
Modified:<br class="gmail_msg">
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br class="gmail_msg">
    cfe/trunk/test/CodeGenCXX/debug-info-class-nolimit.cpp<br class="gmail_msg">
<br class="gmail_msg">
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=281057&r1=281056&r2=281057&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=281057&r1=281056&r2=281057&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)<br class="gmail_msg">
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep  9 12:03:53 2016<br class="gmail_msg">
@@ -1648,9 +1648,13 @@ void CGDebugInfo::completeRequiredType(c<br class="gmail_msg">
   if (DebugKind <= codegenoptions::DebugLineTablesOnly)<br class="gmail_msg">
     return;<br class="gmail_msg">
<br class="gmail_msg">
-  if (const auto *CXXDecl = dyn_cast<CXXRecordDecl>(RD))<br class="gmail_msg">
-    if (CXXDecl->isDynamicClass())<br class="gmail_msg">
-      return;<br class="gmail_msg">
+  // If this is a dynamic class and we're emitting limited debug info, wait<br class="gmail_msg">
+  // until the vtable is emitted to complete the class debug info.<br class="gmail_msg">
+  if (DebugKind <= codegenoptions::LimitedDebugInfo) {<br class="gmail_msg">
+    if (const auto *CXXDecl = dyn_cast<CXXRecordDecl>(RD))<br class="gmail_msg">
+      if (CXXDecl->isDynamicClass())<br class="gmail_msg">
+        return;<br class="gmail_msg">
+  }<br class="gmail_msg">
<br class="gmail_msg">
   if (DebugTypeExtRefs && RD->isFromASTFile())<br class="gmail_msg">
     return;<br class="gmail_msg">
<br class="gmail_msg">
Modified: cfe/trunk/test/CodeGenCXX/debug-info-class-nolimit.cpp<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-class-nolimit.cpp?rev=281057&r1=281056&r2=281057&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-class-nolimit.cpp?rev=281057&r1=281056&r2=281057&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- cfe/trunk/test/CodeGenCXX/debug-info-class-nolimit.cpp (original)<br class="gmail_msg">
+++ cfe/trunk/test/CodeGenCXX/debug-info-class-nolimit.cpp Fri Sep  9 12:03:53 2016<br class="gmail_msg">
@@ -1,8 +1,29 @@<br class="gmail_msg">
-// RUN: %clang_cc1 -triple x86_64-unk-unk -debug-info-kind=standalone -o - -emit-llvm %s | FileCheck %s<br class="gmail_msg">
-// On Darwin, "full" debug info is the default, so really these tests are<br class="gmail_msg">
-// identical, as cc1 no longer chooses the effective value of DebugInfoKind.<br class="gmail_msg">
 // RUN: %clang_cc1 -triple x86_64-apple-darwin -debug-info-kind=standalone -o - -emit-llvm %s | FileCheck %s<br class="gmail_msg">
<br class="gmail_msg">
+// We had a bug in -fstandalone-debug where UnicodeString would not be completed<br class="gmail_msg">
+// when it was required to be complete. This orginally manifested as an<br class="gmail_msg">
+// assertion in CodeView emission on Windows with some dllexport stuff, but it's<br class="gmail_msg">
+// more general than that.<br class="gmail_msg">
+<br class="gmail_msg">
+struct UnicodeString;<br class="gmail_msg">
+struct GetFwdDecl {<br class="gmail_msg">
+  static UnicodeString format;<br class="gmail_msg">
+};<br class="gmail_msg">
+GetFwdDecl force_fwd_decl;<br class="gmail_msg">
+struct UnicodeString {<br class="gmail_msg">
+private:<br class="gmail_msg">
+  virtual ~UnicodeString();<br class="gmail_msg">
+};<br class="gmail_msg">
+struct UseCompleteType {<br class="gmail_msg">
+  UseCompleteType();<br class="gmail_msg">
+  ~UseCompleteType();<br class="gmail_msg">
+  UnicodeString currencySpcAfterSym[1];<br class="gmail_msg">
+};<br class="gmail_msg">
+UseCompleteType require_complete;<br class="gmail_msg">
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "UnicodeString"<br class="gmail_msg">
+// CHECK-NOT:              DIFlagFwdDecl<br class="gmail_msg">
+// CHECK-SAME:             ){{$}}<br class="gmail_msg">
+<br class="gmail_msg">
 namespace rdar14101097_1 { // see also PR16214<br class="gmail_msg">
 // Check that we emit debug info for the definition of a struct if the<br class="gmail_msg">
 // definition is available, even if it's used via a pointer wrapped in a<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
cfe-commits mailing list<br class="gmail_msg">
<a href="mailto:cfe-commits@lists.llvm.org" class="gmail_msg" target="_blank">cfe-commits@lists.llvm.org</a><br class="gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br class="gmail_msg">
</blockquote></div>