Author: benhamilton Date: Wed Mar 21 20:25:22 2018 New Revision: 328175 URL: http://llvm.org/viewvc/llvm-project?rev=328175&view=rev Log: [clang-format] Add a few more Core Graphics identifiers to ObjC heuristic
Summary: We received reports of the Objective-C style guesser getting a false negative on header files like: CGSize SizeOfThing(MyThing thing); This adds more Core Graphics identifiers to the Objective-C style guesser. Test Plan: New tests added. Ran tests with: % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests Reviewers: jolesiak, djasper Reviewed By: jolesiak, djasper Subscribers: krasimir, klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D44632 Modified: cfe/trunk/lib/Format/Format.cpp cfe/trunk/unittests/Format/FormatTest.cpp Modified: cfe/trunk/lib/Format/Format.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=328175&r1=328174&r2=328175&view=diff ============================================================================== --- cfe/trunk/lib/Format/Format.cpp (original) +++ cfe/trunk/lib/Format/Format.cpp Wed Mar 21 20:25:22 2018 @@ -1449,6 +1449,19 @@ private: // Keep this array sorted, since we are binary searching over it. static constexpr llvm::StringLiteral FoundationIdentifiers[] = { "CGFloat", + "CGPoint", + "CGPointMake", + "CGPointZero", + "CGRect", + "CGRectEdge", + "CGRectInfinite", + "CGRectMake", + "CGRectNull", + "CGRectZero", + "CGSize", + "CGSizeMake", + "CGVector", + "CGVectorMake", "NSAffineTransform", "NSArray", "NSAttributedString", @@ -1497,6 +1510,8 @@ private: "NSURLQueryItem", "NSUUID", "NSValue", + "UIImage", + "UIView", }; for (auto &Line : AnnotatedLines) { Modified: cfe/trunk/unittests/Format/FormatTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=328175&r1=328174&r2=328175&view=diff ============================================================================== --- cfe/trunk/unittests/Format/FormatTest.cpp (original) +++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Mar 21 20:25:22 2018 @@ -12108,6 +12108,12 @@ TEST_F(FormatTest, FileAndCode) { EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo.h", "@interface Foo\n@end\n")); EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo", "")); EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo", "@interface Foo\n@end\n")); + EXPECT_EQ(FormatStyle::LK_ObjC, + guessLanguage("foo.h", "int DoStuff(CGRect rect);\n")); + EXPECT_EQ( + FormatStyle::LK_ObjC, + guessLanguage("foo.h", + "#define MY_POINT_MAKE(x, y) CGPointMake((x), (y));\n")); } TEST_F(FormatTest, GuessLanguageWithCpp11AttributeSpecifiers) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits