diff options
author | Andy Gibbs <andyg1001@hotmail.co.uk> | 2013-04-17 08:06:46 +0000 |
---|---|---|
committer | Andy Gibbs <andyg1001@hotmail.co.uk> | 2013-04-17 08:06:46 +0000 |
commit | b42f200777a66b98989160bf3987ce431540a584 (patch) | |
tree | ae167bf593ba9bbf9edccc05072a2e45314c0fd3 /test/PCH | |
parent | a50b57862b99bdd7d056014f429a809647257c8b (diff) |
Extended VerifyDiagnosticConsumer to also verify source file for diagnostic.
VerifyDiagnosticConsumer previously would not check that the diagnostic and
its matching directive referenced the same source file. Common practice was
to create directives that referenced other files but only by line number,
and this led to problems such as when the file containing the directive
didn't have enough lines to match the location of the diagnostic in the
other file, leading to bizarre file formatting and other oddities.
This patch causes VerifyDiagnosticConsumer to match source files as well as
line numbers. Therefore, a new syntax is made available for directives, for
example:
// expected-error@file:line {{diagnostic message}}
This extends the @line feature where "file" is the file where the diagnostic
is generated. The @line syntax is still available and uses the current file
for the diagnostic. "file" can be specified either as a relative or absolute
path - although the latter has less usefulness, I think! The #include search
paths will be used to locate the file and if it is not found an error will be
generated.
The new check is not optional: if the directive is in a different file to the
diagnostic, the file must be specified. Therefore, a number of test-cases
have been updated with regard to this.
This closes out PR15613.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179677 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/PCH')
-rw-r--r-- | test/PCH/cxx-using.cpp | 7 | ||||
-rw-r--r-- | test/PCH/cxx11-statement-attributes.cpp | 3 | ||||
-rw-r--r-- | test/PCH/functions.c | 6 | ||||
-rw-r--r-- | test/PCH/method_pool.m | 12 | ||||
-rw-r--r-- | test/PCH/nonvisible-external-defs.c | 2 | ||||
-rw-r--r-- | test/PCH/reloc.c | 4 | ||||
-rw-r--r-- | test/PCH/tentative-defs.c | 3 | ||||
-rw-r--r-- | test/PCH/typo.cpp | 19 | ||||
-rw-r--r-- | test/PCH/typo.m | 3 |
9 files changed, 24 insertions, 35 deletions
diff --git a/test/PCH/cxx-using.cpp b/test/PCH/cxx-using.cpp index 2ca7dad0dd..2cab1f031a 100644 --- a/test/PCH/cxx-using.cpp +++ b/test/PCH/cxx-using.cpp @@ -6,10 +6,9 @@ // RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s void m() { - D s; // expected-note {{candidate function}} + D s; s.f(); // expected-error {{no matching member}} } - - -// expected-note {{candidate function}} +// expected-note@cxx-using.h:9 {{candidate function}} +// expected-note@cxx-using.h:15 {{candidate function}} diff --git a/test/PCH/cxx11-statement-attributes.cpp b/test/PCH/cxx11-statement-attributes.cpp index 3bb7b40aa9..722ca6e9ff 100644 --- a/test/PCH/cxx11-statement-attributes.cpp +++ b/test/PCH/cxx11-statement-attributes.cpp @@ -4,8 +4,7 @@ // RUN: %clang_cc1 -x c++-header -emit-pch -std=c++11 -o %t %S/Inputs/cxx11-statement-attributes.h // RUN: %clang_cc1 -include-pch %t -std=c++11 -Wimplicit-fallthrough -fsyntax-only %s -o - -verify -// Warning from Inputs/cxx11-statement-attributes.h: -// expected-warning@10 {{fallthrough annotation does not directly precede switch label}} +// expected-warning@Inputs/cxx11-statement-attributes.h:10 {{fallthrough annotation does not directly precede switch label}} void g(int n) { f<1>(n); // expected-note {{in instantiation of function template specialization 'f<1>' requested here}} diff --git a/test/PCH/functions.c b/test/PCH/functions.c index 35e3921058..fa2ba8d29c 100644 --- a/test/PCH/functions.c +++ b/test/PCH/functions.c @@ -4,18 +4,20 @@ // Test with pch. // RUN: %clang_cc1 -emit-pch -o %t %S/functions.h // RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s -// expected-note{{'f1' declared here}} + int f0(int x0, int y0, ...) { return x0 + y0; } -// expected-note{{passing argument to parameter here}} + float *test_f1(int val, double x, double y) { if (val > 5) return f1(x, y); else return f1(x); // expected-error{{too few arguments to function call}} + // expected-note@functions.h:7{{'f1' declared here}} } void test_g0(int *x, float * y) { g0(y); // expected-warning{{incompatible pointer types passing 'float *' to parameter of type 'int *'}} + // expected-note@functions.h:9{{passing argument to parameter here}} g0(x); } diff --git a/test/PCH/method_pool.m b/test/PCH/method_pool.m index 20010fbd1c..139f8ba4a6 100644 --- a/test/PCH/method_pool.m +++ b/test/PCH/method_pool.m @@ -9,13 +9,5 @@ int message_id(id x) { return [x instMethod:17]; // expected-warning{{multiple methods}} } - - - - -/* Whitespace below is significant */ -/* expected-note{{using}} */ - - - -/* expected-note{{also}} */ +/* expected-note@method_pool.h:17{{using}} */ +/* expected-note@method_pool.h:21{{also}} */ diff --git a/test/PCH/nonvisible-external-defs.c b/test/PCH/nonvisible-external-defs.c index 49392ca2fe..092e2c9d9b 100644 --- a/test/PCH/nonvisible-external-defs.c +++ b/test/PCH/nonvisible-external-defs.c @@ -7,4 +7,4 @@ int g(int, float); // expected-error{{conflicting types}} -// expected-note{{previous declaration}} +// expected-note@nonvisible-external-defs.h:10{{previous declaration}} diff --git a/test/PCH/reloc.c b/test/PCH/reloc.c index 4c426e4f77..8dabb8b03d 100644 --- a/test/PCH/reloc.c +++ b/test/PCH/reloc.c @@ -10,5 +10,5 @@ int x = 2; // expected-error{{redefinition}} int y = 5; // expected-error{{redefinition}} -// expected-note{{previous definition}} -// expected-note{{previous definition}} +// expected-note@libroot/usr/include/reloc.h:13{{previous definition}} +// expected-note@libroot/usr/include/reloc2.h:14{{previous definition}} diff --git a/test/PCH/tentative-defs.c b/test/PCH/tentative-defs.c index 0072818a1a..42882307dc 100644 --- a/test/PCH/tentative-defs.c +++ b/test/PCH/tentative-defs.c @@ -5,5 +5,4 @@ // RUN: grep "@variable = common global i32 0" %t | count 1 // RUN: grep "@incomplete_array = common global .*1 x i32" %t | count 1 - -// FIXME: tentative-defs.h expected-warning{{tentative}} +// FIXME: expected-warning@tentative-defs.h:9{{tentative}} diff --git a/test/PCH/typo.cpp b/test/PCH/typo.cpp index f8161d17df..6ab66c2cab 100644 --- a/test/PCH/typo.cpp +++ b/test/PCH/typo.cpp @@ -1,17 +1,14 @@ - -// In header: expected-note{{'boost::function' declared here}} - - -// In header: expected-note{{'boost::graph::adjacency_list' declared here}} - - - -adjacent_list<int, int> g; // expected-error{{no template named 'adjacent_list'; did you mean 'boost::graph::adjacency_list'?}} -Function<int(int)> f; // expected-error{{no template named 'Function'; did you mean 'boost::function'?}} - // Without PCH // RUN: %clang_cc1 -include %S/Inputs/typo.hpp -verify %s // With PCH // RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/Inputs/typo.hpp // RUN: %clang_cc1 -include-pch %t -verify %s + +adjacent_list<int, int> g; +// expected-error@-1{{no template named 'adjacent_list'; did you mean 'boost::graph::adjacency_list'?}} +// expected-note@Inputs/typo.hpp:5{{'boost::graph::adjacency_list' declared here}} + +Function<int(int)> f; +// expected-error@-1{{no template named 'Function'; did you mean 'boost::function'?}} +// expected-note@Inputs/typo.hpp:2{{'boost::function' declared here}} diff --git a/test/PCH/typo.m b/test/PCH/typo.m index c6f0275bc2..876b9438d1 100644 --- a/test/PCH/typo.m +++ b/test/PCH/typo.m @@ -1,6 +1,7 @@ // RUN: %clang_cc1 -x objective-c-header -emit-pch -o %t %S/Inputs/typo.h // RUN: %clang_cc1 -include-pch %t -verify %s -// In header: expected-note{{declared here}} + void f() { [NSstring alloc]; // expected-error{{unknown receiver 'NSstring'; did you mean 'NSString'?}} + // expected-note@Inputs/typo.h:3{{declared here}} } |