<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 2, 2016, at 15:48, Richard Smith <<a href="mailto:richard@metafoo.co.uk" class="">richard@metafoo.co.uk</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Wed, Nov 2, 2016 at 2:34 PM, Jordan Rose via cfe-commits <span dir="ltr" class=""><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="">cfe-commits@lists.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Nov 2, 2016, at 14:31, Richard Smith <<a href="mailto:richard@metafoo.co.uk" target="_blank" class="">richard@metafoo.co.uk</a>> wrote:</div><br class="m_-4883782072324447123Apple-interchange-newline"><div class=""><div dir="auto" class=""><div class=""><div class="gmail_extra"><div class="gmail_quote">On 2 Nov 2016 1:53 pm, "Jordan Rose via cfe-commits" <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="">cfe-commits@lists.llvm.org</a>> wrote:<br type="attribution" class=""><blockquote class="m_-4883782072324447123quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: jrose<br class="">
Date: Wed Nov  2 15:44:07 2016<br class="">
New Revision: 285856<br class="">
<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=285856&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject?rev=285856&view=rev</a><br class="">
Log:<br class="">
Don't require nullability on template parameters in typedefs.<br class="">
<br class="">
Previously the following code would warn on the use of "T":<br class="">
<br class="">
  template <typename T><br class="">
  struct X {<br class="">
    typedef T *type;<br class="">
  };<br class="">
<br class="">
...because nullability is /allowed/ on template parameters (because<br class="">
they could be pointers). (Actually putting nullability on this use of<br class="">
'T' will of course break if the argument is a non-pointer type.)<br class=""></blockquote></div></div></div><div class=""><br class=""></div><div class="">This doesn't make any sense to me. Why would T need to be a pointer type for a nullability qualifier to be valid on a T*?</div></div></div></blockquote><div class=""><br class=""></div></span><div class="">Sorry, this is referring to the following change to the example:</div><div class=""><br class=""></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px" class=""><span class=""><div class=""><div class="">template <typename T></div></div><div class=""><div class="">struct X {</div></div></span><div class=""><div class="">  typedef T _Nullable *type;</div></div><div class=""><div class="">};</div></div></blockquote><div class=""><div class=""><br class=""></div><div class="">This is legal, but of course `X<int>` then produces an error. So we want to accept nullability in this position (in case T is implicitly required to be a pointer type by the definition of X) but not warn when it’s missing (in case it isn’t).</div></div></div></blockquote><div class=""><br class=""></div><div class="">Oh, I see. Your testcase is very confusing, though, since it wraps the problematic use of T in a completely-unrelated pointer type. The actual problem being fixed is much more obvious in a case like this:</div><div class=""><br class=""></div><div class="">int *_Nullable p;</div><div class="">template<typename T> struct X {</div><div class="">  T t; // warns without your fix</div><div class="">};</div><div class=""><br class=""></div><div class="">It'd be easier on future readers of this code to use the more obvious test case here.</div></div></div></div></div></blockquote><br class=""></div><div>Ah, that case doesn’t actually trigger the issue, because a typedef doesn’t require nullability on its outermost pointer type. (It’s assumed that the use site may need to make some uses of the typedef nullable and some non-nullable.)</div><div><br class=""></div><div>We <i class="">do</i> still see this issue for <i class="">fields</i> of type ’T’, but that seemed trickier to deal with. I might have been overthinking it, though.</div><div><br class=""></div><div>Jordan</div><br class=""></body></html>