[cfe-commits] r52337 - /cfe/trunk/test/Sema/format-strings-objc.m

Ted Kremenek kremenek at apple.com
Mon Jun 16 11:01:05 PDT 2008


Author: kremenek
Date: Mon Jun 16 13:01:05 2008
New Revision: 52337

URL: http://llvm.org/viewvc/llvm-project?rev=52337&view=rev
Log:
Add test case for NSString format-string checking.

Added:
    cfe/trunk/test/Sema/format-strings-objc.m

Added: cfe/trunk/test/Sema/format-strings-objc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings-objc.m?rev=52337&view=auto

==============================================================================
--- cfe/trunk/test/Sema/format-strings-objc.m (added)
+++ cfe/trunk/test/Sema/format-strings-objc.m Mon Jun 16 13:01:05 2008
@@ -0,0 +1,36 @@
+// RUN: clang -fsyntax-only -verify %s
+
+//===----------------------------------------------------------------------===//
+// The following code is reduced using delta-debugging from
+// Foundation.h (Mac OS X).
+//
+// It includes the basic definitions for the test cases below.
+// Not including Foundation.h directly makes this test case both svelt and
+// portable to non-Mac platforms.
+//===----------------------------------------------------------------------===//
+
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+ at class NSString, Protocol;
+extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
+typedef struct _NSZone NSZone;
+ at class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+ at protocol NSObject  - (BOOL)isEqual:(id)object; @end
+ at protocol NSCopying  - (id)copyWithZone:(NSZone *)zone; @end
+ at protocol NSMutableCopying  - (id)mutableCopyWithZone:(NSZone *)zone; @end
+ at protocol NSCoding  - (void)encodeWithCoder:(NSCoder *)aCoder; @end
+ at interface NSObject <NSObject> {} @end
+typedef float CGFloat;
+ at interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>    - (NSUInteger)length; @end
+ at interface NSSimpleCString : NSString {} @end
+ at interface NSConstantString : NSSimpleCString @end
+extern void *_NSConstantStringClassReference;
+
+//===----------------------------------------------------------------------===//
+// Test cases.
+//===----------------------------------------------------------------------===//
+
+void check_nslog(unsigned k) {
+  NSLog(@"%d%%", k); // no-warning
+  NSLog(@"%s%lb%d", "unix", 10,20); // expected-warning {{lid conversion '%lb'}}
+}





More information about the cfe-commits mailing list