<div dir="ltr"><div dir="ltr"><div dir="ltr">Thanks for the pointers.. this led me to look a little deeper at some of the other checkers</div><div dir="ltr"><br></div><div>looks like ConstReturnTypeCheck uses getInnerLocStart() to locate the return type</div><div dir="ltr"><br></div><div>Substituting this in seems to find the correct location, but I suspect this doesn't work well for the training return type</div><div><br></div><div dir="ltr"><div dir="ltr">auto retLoc = MatchedDecl->getInnerLocStart();</div><div dir="ltr"><br></div><div dir="ltr">  // This function could be marked [[nodiscard]]</div><div dir="ltr">  diag(retLoc, "function %0 should be marked [[nodiscard]]")</div><div dir="ltr">      << MatchedDecl << FixItHint::CreateInsertion(retLoc, "[[nodiscard]] ");</div><div dir="ltr"><br></div><div dir="ltr"><br></div><div dir="ltr">---------------------------------------------------------------</div><div><br></div><div><div>test.cxx:18:5: warning: function 'empty' should be marked [[nodiscard]] [modernize-use-nodiscard]</div><div>    bool empty() const</div><div>    ^</div><div>    [[nodiscard]]</div><div>test.cxx:22:5: warning: function 'empty' should be marked [[nodiscard]] [modernize-use-nodiscard]</div><div>    bool empty(int val) const</div><div>    ^</div><div>    [[nodiscard]]</div><div>test.cxx:50:5: warning: function 'empty' should be marked [[nodiscard]] [modernize-use-nodiscard]<br></div><div>    const bool empty() const</div><div>    ^</div><div>    [[nodiscard]]</div><div>test.cxx:55:5: warning: function 'empty' should be marked [[nodiscard]] [modernize-use-nodiscard]</div><div>    inline const bool empty() const</div><div>    ^</div><div>    [[nodiscard]]</div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Dec 6, 2018 at 7:19 PM Stephen Kelly via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 06/12/2018 19:08, MyDeveloper Day via cfe-dev wrote:<br>
> I'm currently using (following a series of trail and errors) to find the <br>
> location just before the return type<br>
<br>
Here are the locations you can get for FunctionDecls:<br>
<br>
  <a href="http://ec2-52-14-16-249.us-east-2.compute.amazonaws.com:10240/z/oiG2nf" rel="noreferrer" target="_blank">http://ec2-52-14-16-249.us-east-2.compute.amazonaws.com:10240/z/oiG2nf</a><br>
<br>
See also if you have not already:<br>
<br>
<br>
<a href="https://steveire.wordpress.com/2018/11/11/future-developments-in-clang-query/" rel="noreferrer" target="_blank">https://steveire.wordpress.com/2018/11/11/future-developments-in-clang-query/</a><br>
<br>
If there isn't a location in that output for what you need, then you are <br>
going to have to check the tokens yourself. Many existing clang tidy <br>
checks do things like this due to lack of location for a particular need.<br>
<br>
Thanks,<br>
<br>
Stephen.<br>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>