[clang-format] Improve ObjC guessing heuristic by supporting all @keywords
Summary:
This diff improves the Objective-C guessing heuristic by
replacing the hard-coded list of a subset of Objective-C @keywords
with a general check which supports all @keywords.
I also added a few more Foundation keywords which were missing from
the heuristic.
Test Plan: Unit tests updated. Ran tests with:
% make -j16 FormatTests && ./tools/clang/unittests/Format/FormatTests
Reviewers: djasper, jolesiak
Reviewed By: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D45521
llvm-svn: 329918
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index f7e74ab..98b2656 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1465,6 +1465,7 @@
"NSAffineTransform",
"NSArray",
"NSAttributedString",
+ "NSBlockOperation",
"NSBundle",
"NSCache",
"NSCalendar",
@@ -1480,6 +1481,7 @@
"NSIndexPath",
"NSIndexSet",
"NSInteger",
+ "NSInvocationOperation",
"NSLocale",
"NSMapTable",
"NSMutableArray",
@@ -1494,9 +1496,13 @@
"NSNumber",
"NSNumberFormatter",
"NSObject",
+ "NSOperation",
+ "NSOperationQueue",
+ "NSOperationQueuePriority",
"NSOrderedSet",
"NSPoint",
"NSPointerArray",
+ "NSQualityOfService",
"NSRange",
"NSRect",
"NSRegularExpression",
@@ -1518,10 +1524,7 @@
for (const FormatToken *FormatTok = Line->First; FormatTok;
FormatTok = FormatTok->Next) {
if ((FormatTok->Previous && FormatTok->Previous->is(tok::at) &&
- (FormatTok->isObjCAtKeyword(tok::objc_interface) ||
- FormatTok->isObjCAtKeyword(tok::objc_implementation) ||
- FormatTok->isObjCAtKeyword(tok::objc_protocol) ||
- FormatTok->isObjCAtKeyword(tok::objc_end) ||
+ (FormatTok->Tok.getObjCKeywordID() != tok::objc_not_keyword ||
FormatTok->isOneOf(tok::numeric_constant, tok::l_square,
tok::l_brace))) ||
(FormatTok->Tok.isAnyIdentifier() &&