diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2010-04-02 08:55:10 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2010-04-02 08:55:10 +0000 |
commit | 07b2cfcdb817cc0790420f159a313d61e7241cb9 (patch) | |
tree | d374cdca417e76f1bf101f139dba2db1d10ee8f7 /test/Analysis | |
parent | 1e255aab650a7fa2047fd953cae65b12215280af (diff) | |
download | FreeBSD-src-07b2cfcdb817cc0790420f159a313d61e7241cb9.zip FreeBSD-src-07b2cfcdb817cc0790420f159a313d61e7241cb9.tar.gz |
Update clang to r100181.
Diffstat (limited to 'test/Analysis')
-rw-r--r-- | test/Analysis/PR3991.m | 20 | ||||
-rw-r--r-- | test/Analysis/inline.c | 2 | ||||
-rw-r--r-- | test/Analysis/misc-ps-region-store.m | 45 | ||||
-rw-r--r-- | test/Analysis/no-outofbounds.c | 3 | ||||
-rw-r--r-- | test/Analysis/null-deref-ps.c | 4 | ||||
-rw-r--r-- | test/Analysis/outofbound.c | 23 | ||||
-rw-r--r-- | test/Analysis/plist-output.m | 40 | ||||
-rw-r--r-- | test/Analysis/pr4209.m | 8 | ||||
-rw-r--r-- | test/Analysis/retain-release-region-store.m | 16 | ||||
-rw-r--r-- | test/Analysis/retain-release.m | 9 | ||||
-rw-r--r-- | test/Analysis/uninit-vals-ps-region.m | 7 |
11 files changed, 133 insertions, 44 deletions
diff --git a/test/Analysis/PR3991.m b/test/Analysis/PR3991.m index 3fed57e..c1f238c 100644 --- a/test/Analysis/PR3991.m +++ b/test/Analysis/PR3991.m @@ -35,22 +35,16 @@ typedef struct _NSZone NSZone; @protocol IHGoogleDocsAdapterDelegate - (void)googleDocsAdapter:(IHGoogleDocsAdapter*)inGoogleDocsAdapter accountVerifyIsValid:(BOOL)inIsValid error:(NSError *)inError; @end @interface IHGoogleDocsAdapter : NSObject { } -- (NSArray *)entries; +- (NSArray *)entries; // expected-note {{method definition for 'entries' not found}} @end extern Class const kGDataUseRegisteredClass ; -@interface IHGoogleDocsAdapter () - (GDataFeedDocList *)feedDocList; -- (NSArray *)directoryPathComponents; -- (unsigned int)currentPathComponentIndex; -- (void)setCurrentPathComponentIndex:(unsigned int)aCurrentPathComponentIndex; -- (NSURL *)folderFeedURL; +@interface IHGoogleDocsAdapter () - (GDataFeedDocList *)feedDocList; // expected-note {{method definition for 'feedDocList' not found}} +- (NSArray *)directoryPathComponents; // expected-note {{method definition for 'directoryPathComponents' not found}} +- (unsigned int)currentPathComponentIndex; // expected-note {{method definition for 'currentPathComponentIndex' not found}} +- (void)setCurrentPathComponentIndex:(unsigned int)aCurrentPathComponentIndex; // expected-note {{method definition for 'setCurrentPathComponentIndex:' not found}} +- (NSURL *)folderFeedURL; // expected-note {{method definition for 'folderFeedURL' not found}} @end -@implementation IHGoogleDocsAdapter - (id)initWithUsername:(NSString *)inUsername password:(NSString *)inPassword owner:(NSObject <IHGoogleDocsAdapterDelegate> *)owner { // expected-warning {{incomplete implementation}} \ -// expected-warning {{method definition for 'entries' not found}} \ -// expected-warning {{method definition for 'feedDocList' not found}} \ -// expected-warning {{method definition for 'directoryPathComponents' not found}} \ -// expected-warning {{method definition for 'currentPathComponentIndex' not found}} \ -// expected-warning {{method definition for 'setCurrentPathComponentIndex:' not found}} \ -// expected-warning {{method definition for 'folderFeedURL' not found}} +@implementation IHGoogleDocsAdapter - (id)initWithUsername:(NSString *)inUsername password:(NSString *)inPassword owner:(NSObject <IHGoogleDocsAdapterDelegate> *)owner { // expected-warning {{incomplete implementation}} return 0; } diff --git a/test/Analysis/inline.c b/test/Analysis/inline.c index 13d4f7f..952de73 100644 --- a/test/Analysis/inline.c +++ b/test/Analysis/inline.c @@ -15,6 +15,6 @@ void f2() { } if (x == 2) { int *p = 0; - *p = 3; // expected-warning{{Dereference of null pointer loaded from variable}} + *p = 3; // expected-warning{{Dereference of null pointer (loaded from variable 'p')}} } } diff --git a/test/Analysis/misc-ps-region-store.m b/test/Analysis/misc-ps-region-store.m index 898a33e..d10b9fa 100644 --- a/test/Analysis/misc-ps-region-store.m +++ b/test/Analysis/misc-ps-region-store.m @@ -910,3 +910,48 @@ int rdar_7770737_pos(void) struct rdar_7770737_s f = { .p = (intptr_t)&x }; return x; // expected-warning{{Undefined or garbage value returned to caller}} } + +//===----------------------------------------------------------------------===// +// Test handling of the implicit 'isa' field. For now we don't do anything +// interesting. +//===----------------------------------------------------------------------===// + +void pr6302(id x, Class y) { + // This previously crashed the analyzer (reported in PR 6302) + x->isa = y; +} + +//===----------------------------------------------------------------------===// +// Specially handle global variables that are declared constant. In the +// example below, this forces the loop to take exactly 2 iterations. +//===----------------------------------------------------------------------===// + +const int pr6288_L_N = 2; +void pr6288_(void) { + int x[2]; + int *px[2]; + int i; + for (i = 0; i < pr6288_L_N; i++) + px[i] = &x[i]; + *(px[0]) = 0; // no-warning +} + +void pr6288_pos(int z) { + int x[2]; + int *px[2]; + int i; + for (i = 0; i < z; i++) + px[i] = &x[i]; // expected-warning{{Access out-of-bound array element (buffer overflow)}} + *(px[0]) = 0; // expected-warning{{Dereference of undefined pointer value}} +} + +void pr6288_b(void) { + const int L_N = 2; + int x[2]; + int *px[2]; + int i; + for (i = 0; i < L_N; i++) + px[i] = &x[i]; + *(px[0]) = 0; // no-warning +} + diff --git a/test/Analysis/no-outofbounds.c b/test/Analysis/no-outofbounds.c index f9ac589..771323b 100644 --- a/test/Analysis/no-outofbounds.c +++ b/test/Analysis/no-outofbounds.c @@ -1,6 +1,5 @@ // RUN: %clang_cc1 -analyzer-check-objc-mem -analyze -analyzer-experimental-internal-checks -analyzer-store=basic -verify %s // RUN: %clang_cc1 -analyzer-check-objc-mem -analyze -analyzer-experimental-internal-checks -analyzer-store=region -verify %s -// XFAIL: * //===----------------------------------------------------------------------===// // This file tests cases where we should not flag out-of-bounds warnings. @@ -10,4 +9,6 @@ void f() { long x = 0; char *y = (char*) &x; char c = y[0] + y[1] + y[2]; // no-warning + short *z = (short*) &x; + short s = z[0] + z[1]; // no-warning } diff --git a/test/Analysis/null-deref-ps.c b/test/Analysis/null-deref-ps.c index 704ad33..5376ca0 100644 --- a/test/Analysis/null-deref-ps.c +++ b/test/Analysis/null-deref-ps.c @@ -26,7 +26,7 @@ int f2(struct foo_struct* p) { if (p) p->x = 1; - return p->x++; // expected-warning{{Dereference of null pointer}} + return p->x++; // expected-warning{{Field access results in a dereference of a null pointer (loaded from variable 'p')}} } int f3(char* x) { @@ -57,7 +57,7 @@ int f4(int *p) { return 1; int *q = (int*) x; - return *q; // expected-warning{{Dereference of null pointer loaded from variable 'q'}} + return *q; // expected-warning{{Dereference of null pointer (loaded from variable 'q')}} } int f4_b() { diff --git a/test/Analysis/outofbound.c b/test/Analysis/outofbound.c index 45325e9..e1ff66c 100644 --- a/test/Analysis/outofbound.c +++ b/test/Analysis/outofbound.c @@ -13,3 +13,26 @@ void f2() { int *p = malloc(12); p[3] = 4; // expected-warning{{Access out-of-bound array element (buffer overflow)}} } + +struct three_words { + int c[3]; +}; + +struct seven_words { + int c[7]; +}; + +void f3() { + struct three_words a, *p; + p = &a; + p[0] = a; // no-warning + p[1] = a; // expected-warning{{Access out-of-bound array element (buffer overflow)}} +} + +void f4() { + struct seven_words c; + struct three_words a, *p = (struct three_words *)&c; + p[0] = a; // no-warning + p[1] = a; // no-warning + p[2] = a; // expected-warning{{Access out-of-bound array element (buffer overflow)}} +} diff --git a/test/Analysis/plist-output.m b/test/Analysis/plist-output.m index f49fef5..aa866de 100644 --- a/test/Analysis/plist-output.m +++ b/test/Analysis/plist-output.m @@ -124,7 +124,7 @@ void test_null_field(void) { // CHECK: <array> // CHECK: <dict> // CHECK: <key>line</key><integer>5</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> @@ -135,12 +135,12 @@ void test_null_field(void) { // CHECK: </array> // CHECK: </array> // CHECK: <key>extended_message</key> -// CHECK: <string>Dereference of null pointer loaded from variable 'p'</string> +// CHECK: <string>Dereference of null pointer (loaded from variable 'p')</string> // CHECK: <key>message</key> -// CHECK: <string>Dereference of null pointer loaded from variable 'p'</string> +// CHECK: <string>Dereference of null pointer (loaded from variable 'p')</string> // CHECK: </dict> // CHECK: </array> -// CHECK: <key>description</key><string>Dereference of null pointer loaded from variable 'p'</string> +// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable 'p')</string> // CHECK: <key>category</key><string>Logic error</string> // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>location</key> @@ -262,7 +262,7 @@ void test_null_field(void) { // CHECK: <array> // CHECK: <dict> // CHECK: <key>line</key><integer>11</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> @@ -273,12 +273,12 @@ void test_null_field(void) { // CHECK: </array> // CHECK: </array> // CHECK: <key>extended_message</key> -// CHECK: <string>Dereference of null pointer loaded from variable 'p'</string> +// CHECK: <string>Dereference of null pointer (loaded from variable 'p')</string> // CHECK: <key>message</key> -// CHECK: <string>Dereference of null pointer loaded from variable 'p'</string> +// CHECK: <string>Dereference of null pointer (loaded from variable 'p')</string> // CHECK: </dict> // CHECK: </array> -// CHECK: <key>description</key><string>Dereference of null pointer loaded from variable 'p'</string> +// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable 'p')</string> // CHECK: <key>category</key><string>Logic error</string> // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>location</key> @@ -400,7 +400,7 @@ void test_null_field(void) { // CHECK: <array> // CHECK: <dict> // CHECK: <key>line</key><integer>18</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> @@ -411,12 +411,12 @@ void test_null_field(void) { // CHECK: </array> // CHECK: </array> // CHECK: <key>extended_message</key> -// CHECK: <string>Dereference of null pointer loaded from variable 'q'</string> +// CHECK: <string>Dereference of null pointer (loaded from variable 'q')</string> // CHECK: <key>message</key> -// CHECK: <string>Dereference of null pointer loaded from variable 'q'</string> +// CHECK: <string>Dereference of null pointer (loaded from variable 'q')</string> // CHECK: </dict> // CHECK: </array> -// CHECK: <key>description</key><string>Dereference of null pointer loaded from variable 'q'</string> +// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable 'q')</string> // CHECK: <key>category</key><string>Logic error</string> // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>location</key> @@ -538,7 +538,7 @@ void test_null_field(void) { // CHECK: <array> // CHECK: <dict> // CHECK: <key>line</key><integer>23</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>6</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> @@ -549,12 +549,12 @@ void test_null_field(void) { // CHECK: </array> // CHECK: </array> // CHECK: <key>extended_message</key> -// CHECK: <string>Dereference of null pointer loaded from variable 'p'</string> +// CHECK: <string>Dereference of null pointer (loaded from variable 'p')</string> // CHECK: <key>message</key> -// CHECK: <string>Dereference of null pointer loaded from variable 'p'</string> +// CHECK: <string>Dereference of null pointer (loaded from variable 'p')</string> // CHECK: </dict> // CHECK: </array> -// CHECK: <key>description</key><string>Dereference of null pointer loaded from variable 'p'</string> +// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable 'p')</string> // CHECK: <key>category</key><string>Logic error</string> // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>location</key> @@ -710,7 +710,7 @@ void test_null_field(void) { // CHECK: <array> // CHECK: <dict> // CHECK: <key>line</key><integer>30</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>6</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> @@ -721,12 +721,12 @@ void test_null_field(void) { // CHECK: </array> // CHECK: </array> // CHECK: <key>extended_message</key> -// CHECK: <string>Dereference of null pointer loaded from variable 'p'</string> +// CHECK: <string>Dereference of null pointer (loaded from variable 'p')</string> // CHECK: <key>message</key> -// CHECK: <string>Dereference of null pointer loaded from variable 'p'</string> +// CHECK: <string>Dereference of null pointer (loaded from variable 'p')</string> // CHECK: </dict> // CHECK: </array> -// CHECK: <key>description</key><string>Dereference of null pointer loaded from variable 'p'</string> +// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable 'p')</string> // CHECK: <key>category</key><string>Logic error</string> // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>location</key> diff --git a/test/Analysis/pr4209.m b/test/Analysis/pr4209.m index eb01015..dc1ef7b 100644 --- a/test/Analysis/pr4209.m +++ b/test/Analysis/pr4209.m @@ -48,16 +48,14 @@ CMProfileLocation; @interface GBCategoryChooserPanelController : NSWindowController { GSEbayCategory *rootCategory; } -- (NSMutableDictionary*)categoryDictionaryForCategoryID:(int)inID inRootTreeCategories:(NSMutableArray*)inRootTreeCategories; --(NSString*) categoryID; +- (NSMutableDictionary*)categoryDictionaryForCategoryID:(int)inID inRootTreeCategories:(NSMutableArray*)inRootTreeCategories; // expected-note {{method definition for 'categoryDictionaryForCategoryID:inRootTreeCategories:' not found}} +-(NSString*) categoryID; // expected-note {{method definition for 'categoryID' not found}} @end @interface GSEbayCategory : NSObject <NSCoding> { } - (int) categoryID; - (GSEbayCategory *) parent; - (GSEbayCategory*) subcategoryWithID:(int) inID; -@end @implementation GBCategoryChooserPanelController + (int) chooseCategoryIDFromCategories:(NSArray*) inCategories searchRequest:(GBSearchRequest*)inRequest parentWindow:(NSWindow*) inParent { // expected-warning {{incomplete implementation}} \ -// expected-warning {{method definition for 'categoryDictionaryForCategoryID:inRootTreeCategories:' not found}} \ -// expected-warning {{method definition for 'categoryID' not found}} +@end @implementation GBCategoryChooserPanelController + (int) chooseCategoryIDFromCategories:(NSArray*) inCategories searchRequest:(GBSearchRequest*)inRequest parentWindow:(NSWindow*) inParent { // expected-warning {{incomplete implementation}} return 0; } - (void) addCategory:(EBayCategoryType*)inCategory toRootTreeCategory:(NSMutableArray*)inRootTreeCategories { diff --git a/test/Analysis/retain-release-region-store.m b/test/Analysis/retain-release-region-store.m index 111d4b9..db49b91 100644 --- a/test/Analysis/retain-release-region-store.m +++ b/test/Analysis/retain-release-region-store.m @@ -207,3 +207,19 @@ void rdar7283470_2_positive(void) { [numbers[i] release]; } +void pr6699(int x) { + CFDateRef values[2]; + values[0] = values[1] = 0; + + if (x) { + CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); + values[1] = CFDateCreate(0, t); + } + + if (values[1]) { + // A bug in RegionStore::RemoveDeadBindings caused 'values[1]' to get prematurely + // pruned from the store. + CFRelease(values[1]); // no-warning + } +} + diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m index 675e9a6..3f79c0c 100644 --- a/test/Analysis/retain-release.m +++ b/test/Analysis/retain-release.m @@ -1268,6 +1268,7 @@ CFDateRef returnsRetainedCFDate() { //===----------------------------------------------------------------------===// void panic() __attribute__((noreturn)); +void panic_not_in_hardcoded_list() __attribute__((noreturn)); void test_panic_negative() { signed z = 1; @@ -1291,9 +1292,13 @@ void test_panic_pos_2(int x) { signed z = 1; CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // no-warning if (x) - panic(); - if (!x) panic(); + if (!x) { + // This showed up in <rdar://problem/7796563>, where we silently missed checking + // the function type for noreturn. "panic()" is a hard-coded known panic function + // that isn't always noreturn. + panic_not_in_hardcoded_list(); + } } //===----------------------------------------------------------------------===// diff --git a/test/Analysis/uninit-vals-ps-region.m b/test/Analysis/uninit-vals-ps-region.m index 7e2fff9..69c1ecd 100644 --- a/test/Analysis/uninit-vals-ps-region.m +++ b/test/Analysis/uninit-vals-ps-region.m @@ -59,4 +59,11 @@ void testFoo(Foo *o) { [o passVal:x]; // expected-warning{{Passed-by-value struct argument contains uninitialized data (e.g., field: 'x')}} } +// Test case from <rdar://problem/7780304>. That shows an uninitialized value +// being used in the LHS of a compound assignment. +void rdar_7780304() { + typedef struct s_r7780304 { int x; } s_r7780304; + s_r7780304 b; + b.x |= 1; // expected-warning{{The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage}} +} |