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 | fcc699aee8db46ecbe6d334afde59140dcb7e3af (patch) | |
tree | 0b87254d1979303eb9e7553da8b202511fc1cc04 /clang/test/Frontend | |
parent | dd77743af8623dc77fc9b90548b4343a7259f420 (diff) | |
download | llvm-fcc699aee8db46ecbe6d334afde59140dcb7e3af.zip llvm-fcc699aee8db46ecbe6d334afde59140dcb7e3af.tar.gz llvm-fcc699aee8db46ecbe6d334afde59140dcb7e3af.tar.bz2 |
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.
llvm-svn: 179677
Diffstat (limited to 'clang/test/Frontend')
-rw-r--r-- | clang/test/Frontend/verify.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/test/Frontend/verify.c b/clang/test/Frontend/verify.c index 062e6bd..3d71e04 100644 --- a/clang/test/Frontend/verify.c +++ b/clang/test/Frontend/verify.c @@ -124,3 +124,19 @@ unexpected b; // expected-error@33 1-1 {{unknown type}} // CHECK7-NEXT: Line 2: 2 // CHECK7-NEXT: 2 errors generated. #endif + +#ifdef TEST8 +// RUN: %clang_cc1 -DTEST8 -verify %s 2>&1 | FileCheck -check-prefix=CHECK8 %s + +// expected-warning@nonexistant-file:1 {{ }} +// expected-error@-1 {{file 'nonexistant-file' could not be located}} + +// expected-warning@verify-directive.h: {{ }} +// expected-error@-1 {{missing or invalid line number}} + +// expected-warning@verify-directive.h:1 {{diagnostic}} + +// CHECK8: error: 'warning' diagnostics expected but not seen: +// CHECK8-NEXT: File {{.*}}verify-directive.h Line 1 (directive at {{.*}}verify.c:137): diagnostic +// CHECK8-NEXT: 1 error generated. +#endif |