Index: lib/Format/Format.cpp =================================================================== --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -2129,7 +2129,9 @@ // should be improved over time and probably be done on tokens, not one the // bare content of the file. if (Style.Language == FormatStyle::LK_Cpp && FileName.endswith(".h") && - (Code.contains("\n- (") || Code.contains("\n+ ("))) + (Code.contains("\n- (") || Code.contains("\n+ (") || + Code.contains("\n@end\n") || Code.contains("\n@end ") || + Code.endswith("@end"))) Style.Language = FormatStyle::LK_ObjC; FormatStyle FallbackStyle = getNoStyle(); Index: unittests/Format/FormatTestObjC.cpp =================================================================== --- unittests/Format/FormatTestObjC.cpp +++ unittests/Format/FormatTestObjC.cpp @@ -79,6 +79,17 @@ ASSERT_TRUE((bool)Style); EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language); + Style = getStyle("LLVM", "a.h", "none", "@interface\n" + "@end\n" + "//comment"); + ASSERT_TRUE((bool)Style); + EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language); + + Style = getStyle("LLVM", "a.h", "none", "@interface\n" + "@end //comment"); + ASSERT_TRUE((bool)Style); + EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language); + // No recognizable ObjC. Style = getStyle("LLVM", "a.h", "none", "void f() {}"); ASSERT_TRUE((bool)Style);