<div dir="ltr"><div>I think this looks okay. I think Richard or Aaron might be able to provide a more informed opinion.</div><div><br></div><div>-- HT<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 7, 2020 at 10:06 AM John Marshall via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@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">Ping. I am a newcomer to Clang so don't know who might be appropriate reviewers to CC, so I've CCed a couple of general people from clang/CODE_OWNERS.TXT who may be able to forward as appropriate.<br>
<br>
Thanks,<br>
<br>
    John<br>
<br>
<br>
On 20 Jan 2020, at 16:09, John Marshall wrote:<br>
> <br>
> This small patch improves the diagnostics when calling a function with the wrong number of arguments. For example, given<br>
> <br>
>       int<br>
>       foo(int a, int b);<br>
> <br>
>       int bar() { return foo(1); }<br>
> <br>
> The existing compiler shows the error message and a note for "foo declared here" showing only the "int" line. Ideally it would show the line containing the word "foo" instead, which it does after this patch. Also if the function declaration starts with some incidental macro, a trace of macro expansion is shown which is likely irrelevant. See for example <a href="https://github.com/samtools/htslib/issues/1013" rel="noreferrer" target="_blank">https://github.com/samtools/htslib/issues/1013</a> and PR#23564.<br>
> <br>
> I have not contributed to LLVM before and I am unfamiliar with the difference between getBeginLoc() and getLocation() and the implications of using each. However this patch does fix PR#23564 and perhaps this fix would be mostly a no-brainer for those who are familiar with the code and these two location functions in particular?<br>
<br>
commit e8e73a04dd4274441541cc5fdc553cc4b26c00c3<br>
Author: John Marshall <<a href="mailto:John.W.Marshall@glasgow.ac.uk" target="_blank">John.W.Marshall@glasgow.ac.uk</a>><br>
Date:   Mon Jan 20 14:58:14 2020 +0000<br>
<br>
    Use getLocation() in too few/many arguments diagnostic<br>
<br>
    Use the more accurate location when emitting the location of the<br>
    function being called's prototype in diagnostics emitted when calling<br>
    a function with an incorrect number of arguments.<br>
<br>
    In particular, avoids showing a trace of irrelevant macro expansions<br>
    for "MY_EXPORT static int AwesomeFunction(int, int);". Fixes PR#23564.<br>
<br>
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp<br>
index ffe72c98356..b9d7024f083 100644<br>
--- a/clang/lib/Sema/SemaExpr.cpp<br>
+++ b/clang/lib/Sema/SemaExpr.cpp<br>
@@ -5194,7 +5194,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,<br>
<br>
       // Emit the location of the prototype.<br>
       if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)<br>
-        Diag(FDecl->getBeginLoc(), diag::note_callee_decl) << FDecl;<br>
+        Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;<br>
<br>
       return true;<br>
     }<br>
@@ -5239,7 +5239,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,<br>
<br>
       // Emit the location of the prototype.<br>
       if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)<br>
-        Diag(FDecl->getBeginLoc(), diag::note_callee_decl) << FDecl;<br>
+        Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;<br>
<br>
       // This deletes the extra arguments.<br>
       Call->shrinkNumArgs(NumParams);<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div>