mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-09 09:32:20 +00:00
176981ac58
Now that clang supports printing of multiple lines of code snippet in diagnostics, source ranges in diagnostics that are located in different lines from the diagnosed source location get to be printed if the gap happened to be less than the maximum number of lines clang is allowed to print in. Many of the bad-conversion notes in overload resolution failures have their source location in the function declaration and source range in the argument of function call. This can cause an unnecessarily many lines of snippet printing. This patch fixes it by changing the source range from function callsite to the problematic parameter in function declaration. e.g. ``` void func(int aa, int bb); void test() { func(1, "two"); } ``` BEFORE this patch: ``` source:4:15: error: no matching function for call to 'func' 4 | void test() { func(1, "two"); } | ^~~~ source:1:6: note: candidate function not viable: no known conversion from 'const char[4]' to 'int' for 2nd argument 1 | void func(int aa, int bb); | ^ 2 | 3 | 4 | void test() { func(1, "two"); } | ~~~~~ 1 error generated. ``` AFTER this patch: ``` source:4:15: error: no matching function for call to 'func' 4 | void test() { func(1, "two"); } | ^~~~ source:1:6: note: candidate function not viable: no known conversion from 'const char[4]' to 'int' for 2nd argument 1 | void func(int aa, int bb); | ^ ~~~~~~ ``` Reviewed By: cjdb Differential Revision: https://reviews.llvm.org/D153359
73 lines
2.5 KiB
C++
73 lines
2.5 KiB
C++
// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s --strict-whitespace
|
|
// CHECK: error: no matching function
|
|
template <typename T> struct mcdata {
|
|
typedef int result_type;
|
|
};
|
|
template <class T> typename mcdata<T>::result_type wrap_mean(mcdata<T> const &);
|
|
// CHECK: :{[[@LINE+1]]:19-[[@LINE+1]]:53}: note: {{.*}}: no overload of 'wrap_mean'
|
|
void add_property(double (*)(mcdata<double> const &));
|
|
void f() { add_property(&wrap_mean); }
|
|
|
|
// CHECK: error: no matching function
|
|
// CHECK: :{[[@LINE+1]]:10-[[@LINE+1]]:51}: note: {{.*}}: cannot pass pointer to generic address space
|
|
void baz(__attribute__((opencl_private)) int *Data) {}
|
|
void fizz() {
|
|
int *Nop;
|
|
baz(Nop);
|
|
// CHECK: error: no matching function
|
|
// CHECK: :[[@LINE+1]]:53: note: {{.*}}: 'this' object is in address space '__private'
|
|
__attribute__((opencl_private)) static auto err = [&]() {};
|
|
err();
|
|
}
|
|
|
|
// CHECK: error: no matching function
|
|
struct Bar {
|
|
// CHECK: :{[[@LINE+1]]:26-[[@LINE+1]]:32}: note: {{.*}} would lose const qualifier
|
|
static void foo(int num, int *X) {}
|
|
// CHECK: :{[[@LINE+1]]:17-[[@LINE+1]]:25}: note: {{.*}} no known conversion
|
|
static void foo(int *err, int *x) {}
|
|
};
|
|
void bar(const int *Y) {
|
|
Bar::foo(5, Y);
|
|
}
|
|
|
|
struct InComp;
|
|
|
|
struct A {};
|
|
struct B : public A{};
|
|
// CHECK: error: no matching function
|
|
// CHECK: :{[[@LINE+5]]:36-[[@LINE+5]]:50}: note: {{.*}}: cannot convert initializer
|
|
// CHECK: error: no matching function
|
|
// CHECK: :{[[@LINE+3]]:36-[[@LINE+3]]:50}: note: {{.*}}: cannot convert argument
|
|
// CHECK: error: no matching function
|
|
// CHECK: :{[[@LINE+1]]:11-[[@LINE+1]]:18}: note: {{.*}}: no known conversion
|
|
void hoge(char aa, const char *bb, const A& third);
|
|
|
|
// CHECK: error: no matching function
|
|
// CHECK: :{[[@LINE+1]]:14-[[@LINE+1]]:16}: note: {{.*}}: cannot convert from base class
|
|
void derived(B*);
|
|
|
|
void func(const A &arg) {
|
|
hoge(1, "pass", {{{arg}}});
|
|
InComp *a;
|
|
hoge(1, "pass", a);
|
|
hoge("first", 5, 6);
|
|
A *b;
|
|
derived(b);
|
|
}
|
|
|
|
struct Q {
|
|
// CHECK: error: invalid operands
|
|
// CHECK: :[[@LINE+1]]:6: note: {{.*}}: 'this' argument has type 'const Q'
|
|
Q &operator+(void*);
|
|
};
|
|
|
|
void fuga(const Q q) { q + 3; }
|
|
|
|
template <short T> class Type1 {};
|
|
// CHECK: error: no matching function
|
|
// CHECK: :{[[@LINE+1]]:43-[[@LINE+1]]:54}: note: {{.*}}: expects an lvalue
|
|
template <short T> void Function1(int zz, Type1<T> &x, int ww) {}
|
|
|
|
void Function() { Function1(33, Type1<-42>(), 66); }
|