2012-09-08 12:26:37 +08:00
|
|
|
// RUN: %clang_cc1 -triple i386-apple-darwin8 -analyze -analyzer-checker=core,alpha.core -analyzer-constraints=range -analyzer-store=region -Wno-objc-root-class %s > %t.1 2>&1
|
|
|
|
// RUN: FileCheck -input-file=%t.1 -check-prefix=darwin8 %s
|
|
|
|
// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,alpha.core -analyzer-constraints=range -analyzer-store=region -Wno-objc-root-class %s > %t.2 2>&1
|
|
|
|
// RUN: FileCheck -input-file=%t.2 -check-prefix=darwin9 %s
|
|
|
|
// RUN: %clang_cc1 -triple thumbv6-apple-ios4.0 -analyze -analyzer-checker=core,alpha.core -analyzer-constraints=range -analyzer-store=region -Wno-objc-root-class %s > %t.3 2>&1
|
|
|
|
// RUN: FileCheck -input-file=%t.3 -check-prefix=darwin9 %s
|
2009-04-08 11:07:17 +08:00
|
|
|
|
|
|
|
@interface MyClass {}
|
|
|
|
- (void *)voidPtrM;
|
|
|
|
- (int)intM;
|
|
|
|
- (long long)longlongM;
|
2010-09-30 08:37:10 +08:00
|
|
|
- (unsigned long long)unsignedLongLongM;
|
2009-04-08 11:07:17 +08:00
|
|
|
- (double)doubleM;
|
|
|
|
- (long double)longDoubleM;
|
2009-04-09 13:45:56 +08:00
|
|
|
- (void)voidM;
|
2009-04-08 11:07:17 +08:00
|
|
|
@end
|
|
|
|
@implementation MyClass
|
|
|
|
- (void *)voidPtrM { return (void *)0; }
|
|
|
|
- (int)intM { return 0; }
|
|
|
|
- (long long)longlongM { return 0; }
|
2010-09-30 08:37:10 +08:00
|
|
|
- (unsigned long long)unsignedLongLongM { return 0; }
|
2009-04-08 11:07:17 +08:00
|
|
|
- (double)doubleM { return 0.0; }
|
|
|
|
- (long double)longDoubleM { return 0.0; }
|
2009-04-09 13:45:56 +08:00
|
|
|
- (void)voidM {}
|
2009-04-08 11:07:17 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
void createFoo() {
|
|
|
|
MyClass *obj = 0;
|
|
|
|
|
|
|
|
void *v = [obj voidPtrM]; // no-warning
|
|
|
|
int i = [obj intM]; // no-warning
|
|
|
|
}
|
|
|
|
|
|
|
|
void createFoo2() {
|
|
|
|
MyClass *obj = 0;
|
|
|
|
|
2010-09-30 08:37:10 +08:00
|
|
|
long double ld = [obj longDoubleM];
|
2009-04-08 11:07:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void createFoo3() {
|
2009-05-14 03:16:35 +08:00
|
|
|
MyClass *obj;
|
|
|
|
obj = 0;
|
2009-04-08 11:07:17 +08:00
|
|
|
|
2010-09-30 08:37:10 +08:00
|
|
|
long long ll = [obj longlongM];
|
2009-04-08 11:07:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void createFoo4() {
|
|
|
|
MyClass *obj = 0;
|
|
|
|
|
2010-09-30 08:37:10 +08:00
|
|
|
double d = [obj doubleM];
|
2009-04-08 11:07:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void createFoo5() {
|
2012-02-24 06:51:36 +08:00
|
|
|
MyClass *obj = (id)@"";
|
2009-04-08 11:07:17 +08:00
|
|
|
|
|
|
|
double d = [obj doubleM]; // no-warning
|
|
|
|
}
|
|
|
|
|
2010-09-30 08:37:10 +08:00
|
|
|
void createFoo6() {
|
|
|
|
MyClass *obj;
|
|
|
|
obj = 0;
|
|
|
|
|
|
|
|
unsigned long long ull = [obj unsignedLongLongM];
|
|
|
|
}
|
|
|
|
|
2009-04-09 02:51:08 +08:00
|
|
|
void handleNilPruneLoop(MyClass *obj) {
|
|
|
|
if (!!obj)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Test if [obj intM] evaluates to 0, thus pruning the entire loop.
|
|
|
|
for (int i = 0; i < [obj intM]; i++) {
|
2010-09-30 08:37:10 +08:00
|
|
|
long long j = [obj longlongM];
|
2009-04-09 02:51:08 +08:00
|
|
|
}
|
|
|
|
|
2010-09-30 08:37:10 +08:00
|
|
|
long long j = [obj longlongM];
|
2009-04-09 02:51:08 +08:00
|
|
|
}
|
2009-04-09 13:45:56 +08:00
|
|
|
|
|
|
|
int handleVoidInComma() {
|
|
|
|
MyClass *obj = 0;
|
|
|
|
return [obj voidM], 0;
|
|
|
|
}
|
2009-11-25 06:56:53 +08:00
|
|
|
|
|
|
|
int marker(void) { // control reaches end of non-void function
|
|
|
|
}
|
|
|
|
|
Allow multiple PathDiagnosticConsumers to be used with a BugReporter at the same time.
This fixes several issues:
- removes egregious hack where PlistDiagnosticConsumer would forward to HTMLDiagnosticConsumer,
but diagnostics wouldn't be generated consistently in the same way if PlistDiagnosticConsumer
was used by itself.
- emitting diagnostics to the terminal (using clang's diagnostic machinery) is no longer a special
case, just another PathDiagnosticConsumer. This also magically resolved some duplicate warnings,
as we now use PathDiagnosticConsumer's diagnostic pruning, which has scope for the entire translation
unit, not just the scope of a BugReporter (which is limited to a particular ExprEngine).
As an interesting side-effect, diagnostics emitted to the terminal also have their trailing "." stripped,
just like with diagnostics emitted to plists and HTML. This required some tests to be updated, but now
the tests have higher fidelity with what users will see.
There are some inefficiencies in this patch. We currently generate the report graph (from the ExplodedGraph)
once per PathDiagnosticConsumer, which is a bit wasteful, but that could be pulled up higher in the
logic stack. There is some intended duplication, however, as we now generate different PathDiagnostics (for the same issue)
for different PathDiagnosticConsumers. This is necessary to produce the diagnostics that a particular
consumer expects.
llvm-svn: 162028
2012-08-17 01:45:23 +08:00
|
|
|
// CHECK-darwin8: warning: The receiver of message 'longDoubleM' is nil and returns a value of type 'long double' that will be garbage
|
2009-11-25 06:56:53 +08:00
|
|
|
// CHECK-darwin8: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
|
2012-07-03 04:21:48 +08:00
|
|
|
// CHECK-darwin8: warning: The receiver of message 'doubleM' is nil and returns a value of type 'double' that will be garbage
|
Allow multiple PathDiagnosticConsumers to be used with a BugReporter at the same time.
This fixes several issues:
- removes egregious hack where PlistDiagnosticConsumer would forward to HTMLDiagnosticConsumer,
but diagnostics wouldn't be generated consistently in the same way if PlistDiagnosticConsumer
was used by itself.
- emitting diagnostics to the terminal (using clang's diagnostic machinery) is no longer a special
case, just another PathDiagnosticConsumer. This also magically resolved some duplicate warnings,
as we now use PathDiagnosticConsumer's diagnostic pruning, which has scope for the entire translation
unit, not just the scope of a BugReporter (which is limited to a particular ExprEngine).
As an interesting side-effect, diagnostics emitted to the terminal also have their trailing "." stripped,
just like with diagnostics emitted to plists and HTML. This required some tests to be updated, but now
the tests have higher fidelity with what users will see.
There are some inefficiencies in this patch. We currently generate the report graph (from the ExplodedGraph)
once per PathDiagnosticConsumer, which is a bit wasteful, but that could be pulled up higher in the
logic stack. There is some intended duplication, however, as we now generate different PathDiagnostics (for the same issue)
for different PathDiagnosticConsumers. This is necessary to produce the diagnostics that a particular
consumer expects.
llvm-svn: 162028
2012-08-17 01:45:23 +08:00
|
|
|
// CHECK-darwin8: warning: The receiver of message 'unsignedLongLongM' is nil and returns a value of type 'unsigned long long' that will be garbage
|
2009-11-25 06:56:53 +08:00
|
|
|
// CHECK-darwin8: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
|
2012-03-14 03:32:19 +08:00
|
|
|
|
2010-09-30 08:37:10 +08:00
|
|
|
// CHECK-darwin9-NOT: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
|
|
|
|
// CHECK-darwin9-NOT: warning: The receiver of message 'unsignedLongLongM' is nil and returns a value of type 'unsigned long long' that will be garbage
|
2012-03-14 03:32:19 +08:00
|
|
|
// CHECK-darwin9-NOT: warning: The receiver of message 'doubleM' is nil and returns a value of type 'double' that will be garbage
|
2010-09-30 08:37:10 +08:00
|
|
|
// CHECK-darwin9-NOT: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
|
2012-03-14 03:32:19 +08:00
|
|
|
// CHECK-darwin9-NOT: warning: The receiver of message 'longDoubleM' is nil and returns a value of type 'long double' that will be garbage
|
2010-04-08 02:47:42 +08:00
|
|
|
// CHECK-darwin9: 1 warning generated
|
2010-09-30 08:37:10 +08:00
|
|
|
|