<div dir="ltr"><div>On 23 January 2013 17:52, Matt Beaumont-Gay <span dir="ltr"><<a href="mailto:matthewbg@google.com" target="_blank">matthewbg@google.com</a>></span> wrote:<br></div><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">+        // Cut off the implicit 'this'.<br>
+        if (isa<CXXMethodDecl>(FnDecl))<br>
+          ArgsArray = ArgsArray.slice(1);<br>
<br>
What about static methods?<br></blockquote><div><br></div><div>nonnull.cc:4:15: error: overloaded 'operator<' cannot be a static member<br></div><div>      function</div><div>  static bool operator<(const X&, const char*) __attribute__((nonnull(2)));</div>

<div>              ^</div><div><br></div><div style>I can declare a static non-member, but that makes it a free function, which works fine:</div><div style><div><br></div><div>static bool operator>(const X&, const char*) __attribute__((nonnull(2)));</div>

<div>[...]</div><div><div>nonnull.cc:15:12: warning: null passed to a callee which requires a non-null</div><div>      argument [-Wnonnull]</div><div>  (void)(x > 0);</div><div>           ^ ~</div></div><div><br></div>

<div style>In this case the logic is copied from Sema::CheckFunctionCall in SemaChecking.cpp:</div><div style><br></div><div style><div>  bool IsMemberOperatorCall = isa<CXXOperatorCallExpr>(TheCall) &&</div>

<div>                              isa<CXXMethodDecl>(FDecl);</div><div>[...]</div><div><div>  if (IsMemberOperatorCall) {</div><div>    // If this is a call to a member operator, hide the first argument</div><div>
    // from checkCall.</div>
<div>    // FIXME: Our choice of AST representation here is less than ideal.</div><div>    ++Args;</div><div>    --NumArgs;</div><div>  }</div></div><div><br></div><div style>but I don't need to test for CXXOperatorCallExpr since we know we just created one.</div>

<div style><br></div><div style>Nick</div></div><div><br></div></div><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">


<div><div class="h5">On Wed, Jan 23, 2013 at 5:15 PM, Nick Lewycky <<a href="mailto:nlewycky@google.com">nlewycky@google.com</a>> wrote:<br>
> GCC supports attribute nonnull on overloaded operators, but clang doesn't.<br>
> This patch adds support to the code path around binary operators, as I don't<br>
> think it's possible to make it fire on overloaded unary operators.<br>
><br>
> Please review!<br>
><br>
> Nick<br>
><br>
><br>
</div></div>> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
><br>
</blockquote></div><br></div></div>