<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Jun 20, 2013, at 6:15 AM, Reid Kleckner <<a href="mailto:rnk@google.com">rnk@google.com</a>> wrote:</div><blockquote type="cite"><div dir="ltr">On Tue, Jun 18, 2013 at 10:15 PM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>></span> wrote:<div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
+<br>
+    // In the MSVC++ ABI, make sure arguments have valid destructors.<br>
+    if (Context.getTargetInfo().getCXXABI().isTemporaryDestroyedByCallee())<br>
+      CheckByValParamsForDtors(NewFD);<br>
+<br>
<br>
Please just do this in CheckParameter.  Check for C++ first, then the ABI flag,<br>
then a record type, then call FinalizeVarWithDestructor. :)<br></blockquote><div><br></div><div style="">On further testing, I don't think this works because CheckParameter fires on function declarations, where the record might not be complete:</div>
<div>struct A;</div><div>void foo(A a);  // Can't look at A's dtor here.</div><div><div>class A {</div><div>  friend void bar(A);  // Can't look at A's dtor here.<br></div><div>};</div></div><div><br></div>
<div style="">We don't actually know if the parameter decl is for a definition until ActOnFunctionDeclarator().</div></div></div></div></blockquote><div><br></div>Good point, sorry.<br><br></div><div>Hmm.  It looks like ActOnStartOfFunctionDef, ActOnStartOfObjCMethodDef, ActOnBlockArguments, and addLambdaParameters all have basically the same loop in them, but doing slightly different checks for no particular reason.  And there's already a CheckParmsForFunctionDef method, but it's apparently not called for ObjC methods.</div><div><br></div><div>I think it makes sense to have a single method called in all of these cases which performs the basic checks, sets ownership, and pushes parameters into scope.  That method would be a natural place for your call to FinalizeVarWithDestructor.</div><div><br></div><div>John.</div></body></html>