hazohelet updated this revision to Diff 533971.
hazohelet marked an inline comment as done.
hazohelet edited the summary of this revision.
hazohelet added a comment.

Address comments from @cjdb and @aaron.ballman

- Remove unnecessary cast to void in test
- Add release note


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153267/new/

https://reviews.llvm.org/D153267

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/Misc/diag-func-call-ranges.c
  clang/test/Misc/diag-func-call-ranges.cpp


Index: clang/test/Misc/diag-func-call-ranges.cpp
===================================================================
--- /dev/null
+++ clang/test/Misc/diag-func-call-ranges.cpp
@@ -0,0 +1,14 @@
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info %s 
2>&1 | FileCheck %s --strict-whitespace
+
+// CHECK: error: no matching function for call to 'func'
+
+// CHECK:      :{[[@LINE+1]]:12-[[@LINE+1]]:18}: note: {{.*}} requires single 
argument
+void func( int aa ) {}
+// CHECK:      :{[[@LINE+1]]:12-[[@LINE+3]]:18}: note: {{.*}} requires 3 
arguments
+void func( int aa,
+           int bb,
+           int cc) {}
+
+void arity_mismatch() {
+  func(2, 4);
+}
Index: clang/test/Misc/diag-func-call-ranges.c
===================================================================
--- /dev/null
+++ clang/test/Misc/diag-func-call-ranges.c
@@ -0,0 +1,11 @@
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info %s 
2>&1 | FileCheck %s --strict-whitespace
+
+// CHECK:      :{9:3-9:7}: error: too few arguments
+// CHECK:      :{7:12-7:26}: note: 'func' declared here
+// CHECK:      :{10:3-10:7}{10:13-10:17}: error: too many arguments
+// CHECK:      :{7:12-7:26}: note: 'func' declared here
+void func( int aa, int bb) {}
+void arity_mismatch() {
+  func(3);
+  func(3, 4,5, 6);
+}
Index: clang/lib/Sema/SemaOverload.cpp
===================================================================
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -11037,11 +11037,13 @@
   if (modeCount == 1 && Fn->getParamDecl(0)->getDeclName())
     S.Diag(Fn->getLocation(), diag::note_ovl_candidate_arity_one)
         << (unsigned)FnKindPair.first << (unsigned)FnKindPair.second
-        << Description << mode << Fn->getParamDecl(0) << NumFormalArgs;
+        << Description << mode << Fn->getParamDecl(0) << NumFormalArgs
+        << Fn->getParametersSourceRange();
   else
     S.Diag(Fn->getLocation(), diag::note_ovl_candidate_arity)
         << (unsigned)FnKindPair.first << (unsigned)FnKindPair.second
-        << Description << mode << modeCount << NumFormalArgs;
+        << Description << mode << modeCount << NumFormalArgs
+        << Fn->getParametersSourceRange();
 
   MaybeEmitInheritedConstructorNote(S, Found);
 }
Index: clang/lib/Sema/SemaExpr.cpp
===================================================================
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6449,7 +6449,8 @@
 
       // Emit the location of the prototype.
       if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
-        Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
+        Diag(FDecl->getLocation(), diag::note_callee_decl)
+            << FDecl << FDecl->getParametersSourceRange();
 
       return true;
     }
@@ -6494,7 +6495,8 @@
 
       // Emit the location of the prototype.
       if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
-        Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
+        Diag(FDecl->getLocation(), diag::note_callee_decl)
+            << FDecl << FDecl->getParametersSourceRange();
 
       // This deletes the extra arguments.
       Call->shrinkNumArgs(NumParams);
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -359,6 +359,8 @@
 - The Fix-It emitted for unused labels used to expand to the next line, which 
caused
   visual oddities now that Clang shows more than one line of code snippet. 
This has
   been fixed and the Fix-It now only spans to the end of the ``:``.
+- Clang now underlines the parameter list of function declaration when emitting
+  a note about the mismatch in the number of arguments.
 
 Bug Fixes in This Version
 -------------------------


Index: clang/test/Misc/diag-func-call-ranges.cpp
===================================================================
--- /dev/null
+++ clang/test/Misc/diag-func-call-ranges.cpp
@@ -0,0 +1,14 @@
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s --strict-whitespace
+
+// CHECK: error: no matching function for call to 'func'
+
+// CHECK:      :{[[@LINE+1]]:12-[[@LINE+1]]:18}: note: {{.*}} requires single argument
+void func( int aa ) {}
+// CHECK:      :{[[@LINE+1]]:12-[[@LINE+3]]:18}: note: {{.*}} requires 3 arguments
+void func( int aa,
+           int bb,
+           int cc) {}
+
+void arity_mismatch() {
+  func(2, 4);
+}
Index: clang/test/Misc/diag-func-call-ranges.c
===================================================================
--- /dev/null
+++ clang/test/Misc/diag-func-call-ranges.c
@@ -0,0 +1,11 @@
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s --strict-whitespace
+
+// CHECK:      :{9:3-9:7}: error: too few arguments
+// CHECK:      :{7:12-7:26}: note: 'func' declared here
+// CHECK:      :{10:3-10:7}{10:13-10:17}: error: too many arguments
+// CHECK:      :{7:12-7:26}: note: 'func' declared here
+void func( int aa, int bb) {}
+void arity_mismatch() {
+  func(3);
+  func(3, 4,5, 6);
+}
Index: clang/lib/Sema/SemaOverload.cpp
===================================================================
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -11037,11 +11037,13 @@
   if (modeCount == 1 && Fn->getParamDecl(0)->getDeclName())
     S.Diag(Fn->getLocation(), diag::note_ovl_candidate_arity_one)
         << (unsigned)FnKindPair.first << (unsigned)FnKindPair.second
-        << Description << mode << Fn->getParamDecl(0) << NumFormalArgs;
+        << Description << mode << Fn->getParamDecl(0) << NumFormalArgs
+        << Fn->getParametersSourceRange();
   else
     S.Diag(Fn->getLocation(), diag::note_ovl_candidate_arity)
         << (unsigned)FnKindPair.first << (unsigned)FnKindPair.second
-        << Description << mode << modeCount << NumFormalArgs;
+        << Description << mode << modeCount << NumFormalArgs
+        << Fn->getParametersSourceRange();
 
   MaybeEmitInheritedConstructorNote(S, Found);
 }
Index: clang/lib/Sema/SemaExpr.cpp
===================================================================
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6449,7 +6449,8 @@
 
       // Emit the location of the prototype.
       if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
-        Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
+        Diag(FDecl->getLocation(), diag::note_callee_decl)
+            << FDecl << FDecl->getParametersSourceRange();
 
       return true;
     }
@@ -6494,7 +6495,8 @@
 
       // Emit the location of the prototype.
       if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
-        Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
+        Diag(FDecl->getLocation(), diag::note_callee_decl)
+            << FDecl << FDecl->getParametersSourceRange();
 
       // This deletes the extra arguments.
       Call->shrinkNumArgs(NumParams);
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -359,6 +359,8 @@
 - The Fix-It emitted for unused labels used to expand to the next line, which caused
   visual oddities now that Clang shows more than one line of code snippet. This has
   been fixed and the Fix-It now only spans to the end of the ``:``.
+- Clang now underlines the parameter list of function declaration when emitting
+  a note about the mismatch in the number of arguments.
 
 Bug Fixes in This Version
 -------------------------
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to