@@ -1719,12 +1719,13 @@ void UnwrappedLineParser::parseStructuralElement(
17191719 nextToken ();
17201720 parseBracedList ();
17211721 break ;
1722- } else if (Style.Language == FormatStyle::LK_Java &&
1723- FormatTok->is (Keywords.kw_interface )) {
1722+ }
1723+ if (Style.Language == FormatStyle::LK_Java &&
1724+ FormatTok->is (Keywords.kw_interface )) {
17241725 nextToken ();
17251726 break ;
17261727 }
1727- switch (FormatTok->Tok .getObjCKeywordID ()) {
1728+ switch (bool IsAutoRelease = false ; FormatTok->Tok .getObjCKeywordID ()) {
17281729 case tok::objc_public:
17291730 case tok::objc_protected:
17301731 case tok::objc_package:
@@ -1745,19 +1746,11 @@ void UnwrappedLineParser::parseStructuralElement(
17451746 addUnwrappedLine ();
17461747 return ;
17471748 case tok::objc_autoreleasepool:
1748- nextToken ();
1749- if (FormatTok->is (tok::l_brace)) {
1750- if (Style.BraceWrapping .AfterControlStatement ==
1751- FormatStyle::BWACS_Always) {
1752- addUnwrappedLine ();
1753- }
1754- parseBlock ();
1755- }
1756- addUnwrappedLine ();
1757- return ;
1749+ IsAutoRelease = true ;
1750+ [[fallthrough]];
17581751 case tok::objc_synchronized:
17591752 nextToken ();
1760- if (FormatTok->is (tok::l_paren)) {
1753+ if (!IsAutoRelease && FormatTok->is (tok::l_paren)) {
17611754 // Skip synchronization object
17621755 parseParens ();
17631756 }
@@ -3086,11 +3079,10 @@ void UnwrappedLineParser::parseTryCatch() {
30863079 if (FormatTok->is (tok::at))
30873080 nextToken ();
30883081 if (!(FormatTok->isOneOf (tok::kw_catch, Keywords.kw___except ,
3089- tok::kw___finally) ||
3082+ tok::kw___finally, tok::objc_catch,
3083+ tok::objc_finally) ||
30903084 ((Style.Language == FormatStyle::LK_Java || Style.isJavaScript ()) &&
3091- FormatTok->is (Keywords.kw_finally )) ||
3092- (FormatTok->isObjCAtKeyword (tok::objc_catch) ||
3093- FormatTok->isObjCAtKeyword (tok::objc_finally)))) {
3085+ FormatTok->is (Keywords.kw_finally )))) {
30943086 break ;
30953087 }
30963088 nextToken ();
@@ -4162,17 +4154,15 @@ void UnwrappedLineParser::parseObjCProtocolList() {
41624154 do {
41634155 nextToken ();
41644156 // Early exit in case someone forgot a close angle.
4165- if (FormatTok->isOneOf (tok::semi, tok::l_brace) ||
4166- FormatTok->isObjCAtKeyword (tok::objc_end)) {
4157+ if (FormatTok->isOneOf (tok::semi, tok::l_brace, tok::objc_end))
41674158 return ;
4168- }
41694159 } while (!eof () && FormatTok->isNot (tok::greater));
41704160 nextToken (); // Skip '>'.
41714161}
41724162
41734163void UnwrappedLineParser::parseObjCUntilAtEnd () {
41744164 do {
4175- if (FormatTok->isObjCAtKeyword (tok::objc_end)) {
4165+ if (FormatTok->is (tok::objc_end)) {
41764166 nextToken ();
41774167 addUnwrappedLine ();
41784168 break ;
@@ -4195,8 +4185,7 @@ void UnwrappedLineParser::parseObjCUntilAtEnd() {
41954185}
41964186
41974187void UnwrappedLineParser::parseObjCInterfaceOrImplementation () {
4198- assert (FormatTok->Tok .getObjCKeywordID () == tok::objc_interface ||
4199- FormatTok->Tok .getObjCKeywordID () == tok::objc_implementation);
4188+ assert (FormatTok->isOneOf (tok::objc_interface, tok::objc_implementation));
42004189 nextToken ();
42014190 nextToken (); // interface name
42024191
@@ -4244,10 +4233,8 @@ void UnwrappedLineParser::parseObjCLightweightGenerics() {
42444233 do {
42454234 nextToken ();
42464235 // Early exit in case someone forgot a close angle.
4247- if (FormatTok->isOneOf (tok::semi, tok::l_brace) ||
4248- FormatTok->isObjCAtKeyword (tok::objc_end)) {
4236+ if (FormatTok->isOneOf (tok::semi, tok::l_brace, tok::objc_end))
42494237 break ;
4250- }
42514238 if (FormatTok->is (tok::less)) {
42524239 ++NumOpenAngles;
42534240 } else if (FormatTok->is (tok::greater)) {
@@ -4261,7 +4248,7 @@ void UnwrappedLineParser::parseObjCLightweightGenerics() {
42614248// Returns true for the declaration/definition form of @protocol,
42624249// false for the expression form.
42634250bool UnwrappedLineParser::parseObjCProtocol () {
4264- assert (FormatTok->Tok . getObjCKeywordID () == tok::objc_protocol);
4251+ assert (FormatTok->is ( tok::objc_protocol) );
42654252 nextToken ();
42664253
42674254 if (FormatTok->is (tok::l_paren)) {
0 commit comments