-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang][Diagnostics] Provide parameter source range to arity-mismatch…
… notes Consider the following piece of code: ``` void func( int aa, int bb, int cc) {} void arity_mismatch() { func(2, 4); } ``` BEFORE: ``` source.cpp:6:3: error: no matching function for call to 'func' 6 | func(2, 4); | ^~~~ source.cpp:1:6: note: candidate function not viable: requires 3 arguments, but 2 were provided 1 | void func( int aa, | ^ ``` AFTER: ``` source.cpp:6:3: error: no matching function for call to 'func' 6 | func(2, 4); | ^~~~ source.cpp:1:6: note: candidate function not viable: requires 3 arguments, but 2 were provided 1 | void func( int aa, | ^ ~~~~~~~ 2 | int bb, | ~~~~~~~ 3 | int cc) {} | ~~~~~~ ``` Reviewed By: cjdb, aaron.ballman Differential Revision: https://reviews.llvm.org/D153267
- Loading branch information
Showing
5 changed files
with
35 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |