<div dir="ltr">I was thinking it might help some of the null-dereference issues if more things were to be passed as references. Is there a particular reason to use pointers instead? It seems there are several places which accept pointers and assume they&#39;re not null, which isn&#39;t really safe.<div><br></div><div>(And, there&#39;s probably some work to be done adding `const` in a bunch of places.)</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div>Jacob<br></div></div></div></div>
<br><div class="gmail_quote">On Mon, Dec 14, 2015 at 11:34 AM, John McCall <span dir="ltr">&lt;<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><span class=""><blockquote type="cite"><div>On Dec 12, 2015, at 4:20 PM, Michael Gottesman via swift-dev &lt;<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>&gt; wrote:</div><div><div style="word-wrap:break-word">In general, we have not been particularly disciplined in this regard. I would suggest following what is being done locally in the file you are modifying, i.e. FuncDecl */TypeChecker &amp; as per the LLVM style guide.</div></div></blockquote><div><br></div></span>There are common rules at work here that govern most situations.  We almost always pass around objects that are part of the language representation as either pointers (e.g. AST/SIL/LLVM nodes) or values (e.g. Type, SILDeclRef); pretty much everything else is passed around as a reference, especially classes that manage the creation or manipulation of the language representation (e.g. IRGenModule, TypeChecker).</div><div><br></div><div>The biggest grey area is for those parts of the language representation that are either globally or contextually singleton, e.g. ASTContext and SILFunction; these are almost always stored as references.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>John.</div></font></span><span class=""><div><br><blockquote type="cite"><div><div style="word-wrap:break-word"><div><br></div><div>Michael<br><div><br><div><blockquote type="cite"><div>On Dec 12, 2015, at 3:15 PM, Jacob Bandes-Storch via swift-dev &lt;<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>&gt; wrote:</div><br><div><div dir="ltr">I&#39;ve noticed a mix of pointers (FuncDecl*) and references (TypeChecker&amp;) in the C++ codebase. Is there a particular reason for this? Perhaps a style guide?<div><br clear="all"><div><div><div dir="ltr"><div>Jacob<br></div></div></div></div>
</div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=BsPB5S3Z2usbY-2FzcCsd-2F2r4MihYe9FiKHjzH65yItK42zGIS-2BoUlT20IhcT-2BMoNTJwioULyBGgd3iT1Ge-2BfqKpy9PTC-2BNFZ1LSfqFaLA4EUIrqazQsR52uvMuicqqhAUGjelm9Roux4dW189khi6So0v60SFw4nH0hqnls1jkQzEdNI8ic1kD18LSfvWcrb-2B6CNdYM5Xsvf3-2BjrdCsv5-2BIT-2FOy319BWL6qWLySR-2FSe4-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important">
_______________________________________________<br>swift-dev mailing list<br><a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-dev" target="_blank">https://lists.swift.org/mailman/listinfo/swift-dev</a><br></div></blockquote></div><br></div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=hWKWvOREWCPT32eVzNXOV7yIWXgGOvlMtgjKbOieJnYFY9LtG5Z7MeRP-2BtSh2C6f0rJ09hXed4krrPDcqHYF6NtGMYRZNgAeGrixhNAciP6WiKTsk37dYIZ64F4VGxgjBErxWWMwbQsaBsAIZIEVr2iV9tbFuAwJLUE3rwyASpbFgvrxRuCNpVOqYMLBXAEhGvPLF0j5ZH18CE37aVKnkN7r7fQoujEqLXi13-2BEpgbI-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important">
</div>
_______________________________________________<br>swift-dev mailing list<br><a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-dev" target="_blank">https://lists.swift.org/mailman/listinfo/swift-dev</a><br></div></blockquote></div><br></span></div></blockquote></div><br></div></div>