"NSAffineTransform",
"NSArray",
"NSAttributedString",
+ "NSBundle",
"NSCache",
+ "NSCalendar",
"NSCharacterSet",
"NSCountedSet",
"NSData",
"NSMutableString",
"NSNumber",
"NSNumberFormatter",
+ "NSObject",
"NSOrderedSet",
"NSPoint",
"NSPointerArray",
"NSSet",
"NSSize",
"NSString",
+ "NSTimeZone",
"NSUInteger",
"NSURL",
"NSURLComponents",
"NSURLQueryItem",
"NSUUID",
+ "NSValue",
};
for (auto &Line : AnnotatedLines) {
- for (FormatToken *FormatTok = Line->First->Next; FormatTok;
+ for (FormatToken *FormatTok = Line->First; FormatTok;
FormatTok = FormatTok->Next) {
- if ((FormatTok->Previous->is(tok::at) &&
+ if ((FormatTok->Previous && FormatTok->Previous->is(tok::at) &&
(FormatTok->isObjCAtKeyword(tok::objc_interface) ||
FormatTok->isObjCAtKeyword(tok::objc_implementation) ||
FormatTok->isObjCAtKeyword(tok::objc_protocol) ||
ASSERT_TRUE((bool)Style);
EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
- Style = getStyle("{}", "a.h", "none", "extern NSString *kFoo;\n");
- ASSERT_TRUE((bool)Style);
- EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
-
Style =
getStyle("{}", "a.h", "none", "typedef NS_ENUM(NSInteger, Foo) {};\n");
ASSERT_TRUE((bool)Style);
ASSERT_TRUE((bool)Style);
EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
- Style = getStyle("{}", "a.h", "none", "extern NSInteger Foo();\n");
- ASSERT_TRUE((bool)Style);
- EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
-
Style =
getStyle("{}", "a.h", "none", "inline void Foo() { Log(@\"Foo\"); }\n");
ASSERT_TRUE((bool)Style);
"inline void Foo() { int foo[] = {1, 2, 3}; }\n");
ASSERT_TRUE((bool)Style);
EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
+
+ // ObjC characteristic types.
+ Style = getStyle("{}", "a.h", "none", "extern NSString *kFoo;\n");
+ ASSERT_TRUE((bool)Style);
+ EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+ Style = getStyle("{}", "a.h", "none", "extern NSInteger Foo();\n");
+ ASSERT_TRUE((bool)Style);
+ EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+ Style = getStyle("{}", "a.h", "none", "NSObject *Foo();\n");
+ ASSERT_TRUE((bool)Style);
+ EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+ Style = getStyle("{}", "a.h", "none", "NSSet *Foo();\n");
+ ASSERT_TRUE((bool)Style);
+ EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
}
TEST_F(FormatTestObjC, FormatObjCTryCatch) {