<div dir="ltr">Oops, forgot to reply-all. Sorry Adrian.<div><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">David Blaikie</b> <span dir="ltr"><<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>></span><br>Date: Mon, Oct 5, 2015 at 11:45 AM<br>Subject: Re: r249328 - Undo the unique_ptr'fication of CodeGenABITypes::CGM introduced in r248762.<br>To: Adrian Prantl <<a href="mailto:aprantl@apple.com">aprantl@apple.com</a>><br><br><br><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Mon, Oct 5, 2015 at 11:43 AM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>On Mon, Oct 5, 2015 at 10:41 AM, Adrian Prantl via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: adrian<br>
Date: Mon Oct  5 12:41:16 2015<br>
New Revision: 249328<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=249328&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=249328&view=rev</a><br>
Log:<br>
Undo the unique_ptr'fication of CodeGenABITypes::CGM introduced in r248762.<br>
include/clang/CodeGenABITypes.h is in meant to be included by external<br>
users,</blockquote></span></div></div></div></blockquote><div><br></div></span><div>Oh, and it might be handy to have some kind of test coverage for this - however that might happen. (I wonder if a "unit test" that didn't even have any executable code/tests and just included the header, would've caught this at compile-time rather than, presumably, when it was integrated into another codebase with the actual external use of the header - though a more fully fledged test would be nice, of course)</div><div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> but using a unique_ptr on the private CodeGenModule introduces a</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
dependency on the type definition that prevents such a use.<br></blockquote><div><br></div></span><div>If you just make the CodeGenABITypes dtor out of line (but still defaulted) this will address the issue without needing to use raw pointers/manual delete:<br><br>foo.h:<br><br>struct bar;<br>struct foo {<br>  unique_ptr<bar> b;<br>  foo();<br>  ~foo();</div><div>};<br><br>foo.cpp:<br>struct bar {<br>};</div><div>foo::~foo() = default;<br><br><br>We have similar code in a variety of parts of LLVM/Clang to cope with calling dtors of types that are implementation details, etc.</div><div><div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
NFC<br>
<br>
Modified:<br>
    cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h<br>
    cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp<br>
<br>
Modified: cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h?rev=249328&r1=249327&r2=249328&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h?rev=249328&r1=249327&r2=249328&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h (original)<br>
+++ cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h Mon Oct  5 12:41:16 2015<br>
@@ -52,6 +52,7 @@ class CodeGenABITypes<br>
 public:<br>
   CodeGenABITypes(ASTContext &C, llvm::Module &M,<br>
                   CoverageSourceInfo *CoverageInfo = nullptr);<br>
+  ~CodeGenABITypes();<br>
<br>
   /// These methods all forward to methods in the private implementation class<br>
   /// CodeGenTypes.<br>
@@ -79,7 +80,7 @@ private:<br>
   std::unique_ptr<PreprocessorOptions> PPO;<br>
<br>
   /// The CodeGenModule we use get to the CodeGenTypes object.<br>
-  std::unique_ptr<CodeGen::CodeGenModule> CGM;<br>
+  CodeGen::CodeGenModule *CGM;<br>
 };<br>
<br>
 }  // end namespace CodeGen<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp?rev=249328&r1=249327&r2=249328&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp?rev=249328&r1=249327&r2=249328&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp Mon Oct  5 12:41:16 2015<br>
@@ -33,6 +33,11 @@ CodeGenABITypes::CodeGenABITypes(ASTCont<br>
       CGM(new CodeGen::CodeGenModule(C, *HSO, *PPO, *CGO, M, C.getDiagnostics(),<br>
                                      CoverageInfo)) {}<br>
<br>
+CodeGenABITypes::~CodeGenABITypes()<br>
+{<br>
+  delete CGM;<br>
+}<br>
+<br>
 const CGFunctionInfo &<br>
 CodeGenABITypes::arrangeObjCMessageSendSignature(const ObjCMethodDecl *MD,<br>
                                                  QualType receiverType) {<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="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div></div><br></div></div>
</blockquote></div></div></div><br></div></div>
</div><br></div></div>