llvm-project/clang/test/Modules/method_pool.m
Andy Gibbs fcc699aee8 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
2013-04-17 08:06:46 +00:00

65 lines
1.4 KiB
Objective-C

// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -I %S/Inputs %s -verify
@import MethodPoolA;
@interface D
- (void)method5:(D*)obj;
@end
// expected-note@Inputs/MethodPoolA.h:7{{using}}
// expected-note@Inputs/MethodPoolB.h:12{{also found}}
void testMethod1(id object) {
[object method1];
}
void testMethod2(id object) {
[object method2:1];
}
void testMethod4(id object) {
[object method4]; // expected-warning{{instance method '-method4' not found (return type defaults to 'id')}}
}
void testMethod5(id object, D* d) {
[object method5:d];
}
@import MethodPoolB;
void testMethod1Again(id object) {
[object method1];
}
void testMethod2Again(id object) {
[object method2:1]; // expected-warning{{multiple methods named 'method2:' found}}
}
void testMethod3(id object) {
[object method3]; // expected-warning{{instance method '-method3' not found (return type defaults to 'id')}}
}
@import MethodPoolB.Sub;
void testMethod3Again(id object) {
char *str = [object method3]; // okay: only found in MethodPoolB.Sub
}
@import MethodPoolA.Sub;
void testMethod3AgainAgain(id object) {
[object method3]; // expected-warning{{multiple methods named 'method3' found}}
// expected-note@Inputs/MethodPoolBSub.h:2{{using}}
// expected-note@Inputs/MethodPoolASub.h:2{{also found}}
}
void testMethod4Again(id object) {
[object method4];
}
void testMethod5Again(id object, D* d) {
[object method5:d];
}