ParseInit.cpp revision 234353
1139749Simp//===--- ParseInit.cpp - Initializer Parsing ------------------------------===// 24435Sgibbs// 38876Srgrimes// The LLVM Compiler Infrastructure 4963Sats// 54435Sgibbs// This file is distributed under the University of Illinois Open Source 64435Sgibbs// License. See LICENSE.TXT for details. 74435Sgibbs// 84435Sgibbs//===----------------------------------------------------------------------===// 913765Smpp// 108876Srgrimes// This file implements initializer parsing as specified by C99 6.7.8. 114435Sgibbs// 124435Sgibbs//===----------------------------------------------------------------------===// 134435Sgibbs 144435Sgibbs#include "clang/Parse/Parser.h" 154435Sgibbs#include "clang/Parse/ParseDiagnostic.h" 164435Sgibbs#include "RAIIObjectsForParser.h" 174435Sgibbs#include "clang/Sema/Designator.h" 184435Sgibbs#include "clang/Sema/Scope.h" 194435Sgibbs#include "llvm/ADT/SmallString.h" 204435Sgibbs#include "llvm/Support/raw_ostream.h" 218876Srgrimesusing namespace clang; 2250477Speter 237510Sjkh 244435Sgibbs/// MayBeDesignationStart - Return true if the current token might be the start 254435Sgibbs/// of a designator. If we can tell it is impossible that it is a designator, 2651673Smdodd/// return false. 2751673Smdoddbool Parser::MayBeDesignationStart() { 2816374Snate switch (Tok.getKind()) { 2951673Smdodd default: 3051673Smdodd return false; 3116374Snate 3216374Snate case tok::period: // designator: '.' identifier 334435Sgibbs return true; 344435Sgibbs 354435Sgibbs case tok::l_square: { // designator: array-designator 364435Sgibbs if (!PP.getLangOpts().CPlusPlus0x) 374435Sgibbs return true; 38117700Smarkm 3930398Sitojun // C++11 lambda expressions and C99 designators can be ambiguous all the 404435Sgibbs // way through the closing ']' and to the next character. Handle the easy 414435Sgibbs // cases here, and fall back to tentative parsing if those fail. 424435Sgibbs switch (PP.LookAhead(0).getKind()) { 434435Sgibbs case tok::equal: 444435Sgibbs case tok::r_square: 4514259Sgibbs // Definitely starts a lambda expression. 464435Sgibbs return false; 474435Sgibbs 484435Sgibbs case tok::amp: 494435Sgibbs case tok::kw_this: 504435Sgibbs case tok::identifier: 514435Sgibbs // We have to do additional analysis, because these could be the 524435Sgibbs // start of a constant expression or a lambda capture list. 534435Sgibbs break; 544435Sgibbs 554435Sgibbs default: 564435Sgibbs // Anything not mentioned above cannot occur following a '[' in a 574435Sgibbs // lambda expression. 584435Sgibbs return true; 594435Sgibbs } 604435Sgibbs 614435Sgibbs // Handle the complicated case below. 62121492Simp break; 63121588Simp } 644435Sgibbs case tok::identifier: // designation: identifier ':' 65963Sats return PP.LookAhead(0).is(tok::colon); 664435Sgibbs } 67963Sats 6813765Smpp // Parse up to (at most) the token after the closing ']' to determine 69963Sats // whether this is a C99 designator or a lambda. 70963Sats TentativeParsingAction Tentative(*this); 71963Sats ConsumeBracket(); 72963Sats while (true) { 73963Sats switch (Tok.getKind()) { 74963Sats case tok::equal: 75963Sats case tok::amp: 76963Sats case tok::identifier: 77117700Smarkm case tok::kw_this: 78117700Smarkm // These tokens can occur in a capture list or a constant-expression. 79117700Smarkm // Keep looking. 80963Sats ConsumeToken(); 81963Sats continue; 82117700Smarkm 83117700Smarkm case tok::comma: 844435Sgibbs // Since a comma cannot occur in a constant-expression, this must 8554201Smdodd // be a lambda. 8654201Smdodd Tentative.Revert(); 8754201Smdodd return false; 8854201Smdodd 8954201Smdodd case tok::r_square: { 9054201Smdodd // Once we hit the closing square bracket, we look at the next 9154201Smdodd // token. If it's an '=', this is a designator. Otherwise, it's a 92117700Smarkm // lambda expression. This decision favors lambdas over the older 93117700Smarkm // GNU designator syntax, which allows one to omit the '=', but is 9454201Smdodd // consistent with GCC. 9554201Smdodd ConsumeBracket(); 9654201Smdodd tok::TokenKind Kind = Tok.getKind(); 97117700Smarkm Tentative.Revert(); 98117700Smarkm return Kind == tok::equal; 99117700Smarkm } 100117700Smarkm 101117700Smarkm default: 102117700Smarkm // Anything else cannot occur in a lambda capture list, so it 103117700Smarkm // must be a designator. 10454201Smdodd Tentative.Revert(); 105117700Smarkm return true; 106117700Smarkm } 107117700Smarkm } 108117700Smarkm 109117700Smarkm return true; 110963Sats} 11154201Smdodd 11254201Smdoddstatic void CheckArrayDesignatorSyntax(Parser &P, SourceLocation Loc, 113963Sats Designation &Desig) { 114963Sats // If we have exactly one array designator, this used the GNU 115963Sats // 'designation: array-designator' extension, otherwise there should be no 116963Sats // designators at all! 117963Sats if (Desig.getNumDesignators() == 1 && 118963Sats (Desig.getDesignator(0).isArrayDesignator() || 119963Sats Desig.getDesignator(0).isArrayRangeDesignator())) 120963Sats P.Diag(Loc, diag::ext_gnu_missing_equal_designator); 121963Sats else if (Desig.getNumDesignators() > 0) 1224435Sgibbs P.Diag(Loc, diag::err_expected_equal_designator); 1234435Sgibbs} 1244435Sgibbs 1254435Sgibbs/// ParseInitializerWithPotentialDesignator - Parse the 'initializer' production 1264435Sgibbs/// checking to see if the token stream starts with a designator. 1274435Sgibbs/// 128963Sats/// designation: 129963Sats/// designator-list '=' 130963Sats/// [GNU] array-designator 1314435Sgibbs/// [GNU] identifier ':' 132963Sats/// 133963Sats/// designator-list: 134963Sats/// designator 135963Sats/// designator-list designator 136963Sats/// 137121492Simp/// designator: 138963Sats/// array-designator 139963Sats/// '.' identifier 140963Sats/// 141963Sats/// array-designator: 142963Sats/// '[' constant-expression ']' 143963Sats/// [GNU] '[' constant-expression '...' constant-expression ']' 1444435Sgibbs/// 145963Sats/// NOTE: [OBC] allows '[ objc-receiver objc-message-args ]' as an 146963Sats/// initializer (because it is an expression). We need to consider this case 1474435Sgibbs/// when parsing array designators. 148963Sats/// 1494435SgibbsExprResult Parser::ParseInitializerWithPotentialDesignator() { 1504435Sgibbs 151963Sats // If this is the old-style GNU extension: 152963Sats // designation ::= identifier ':' 153963Sats // Handle it as a field designator. Otherwise, this must be the start of a 154963Sats // normal expression. 155963Sats if (Tok.is(tok::identifier)) { 156963Sats const IdentifierInfo *FieldName = Tok.getIdentifierInfo(); 157963Sats 1584435Sgibbs SmallString<256> NewSyntax; 159121902Simp llvm::raw_svector_ostream(NewSyntax) << '.' << FieldName->getName() 160963Sats << " = "; 161963Sats 162963Sats SourceLocation NameLoc = ConsumeToken(); // Eat the identifier. 163963Sats 164963Sats assert(Tok.is(tok::colon) && "MayBeDesignationStart not working properly!"); 165963Sats SourceLocation ColonLoc = ConsumeToken(); 166963Sats 1674435Sgibbs Diag(NameLoc, diag::ext_gnu_old_style_field_designator) 168963Sats << FixItHint::CreateReplacement(SourceRange(NameLoc, ColonLoc), 169963Sats NewSyntax.str()); 1704435Sgibbs 171963Sats Designation D; 172963Sats D.AddDesignator(Designator::getField(FieldName, SourceLocation(), NameLoc)); 17349070Shosokawa return Actions.ActOnDesignatedInitializer(D, ColonLoc, true, 174963Sats ParseInitializer()); 175963Sats } 176963Sats 177963Sats // Desig - This is initialized when we see our first designator. We may have 1784435Sgibbs // an objc message send with no designator, so we don't want to create this 179963Sats // eagerly. 180963Sats Designation Desig; 181963Sats 182963Sats // Parse each designator in the designator list until we find an initializer. 183963Sats while (Tok.is(tok::period) || Tok.is(tok::l_square)) { 184963Sats if (Tok.is(tok::period)) { 185963Sats // designator: '.' identifier 186963Sats SourceLocation DotLoc = ConsumeToken(); 187963Sats 188963Sats if (Tok.isNot(tok::identifier)) { 1894435Sgibbs Diag(Tok.getLocation(), diag::err_expected_field_designator); 190963Sats return ExprError(); 191963Sats } 192963Sats 193963Sats Desig.AddDesignator(Designator::getField(Tok.getIdentifierInfo(), DotLoc, 194963Sats Tok.getLocation())); 195963Sats ConsumeToken(); // Eat the identifier. 196963Sats continue; 197963Sats } 198963Sats 199963Sats // We must have either an array designator now or an objc message send. 2004435Sgibbs assert(Tok.is(tok::l_square) && "Unexpected token!"); 201963Sats 202963Sats // Handle the two forms of array designator: 203963Sats // array-designator: '[' constant-expression ']' 204963Sats // array-designator: '[' constant-expression '...' constant-expression ']' 205963Sats // 206963Sats // Also, we have to handle the case where the expression after the 207963Sats // designator an an objc message send: '[' objc-message-expr ']'. 208963Sats // Interesting cases are: 209963Sats // [foo bar] -> objc message send 210963Sats // [foo] -> array designator 211963Sats // [foo ... bar] -> array designator 212963Sats // [4][foo bar] -> obsolete GNU designation with objc message send. 213963Sats // 214963Sats // We do not need to check for an expression starting with [[ here. If it 215963Sats // contains an Objective-C message send, then it is not an ill-formed 216963Sats // attribute. If it is a lambda-expression within an array-designator, then 217963Sats // it will be rejected because a constant-expression cannot begin with a 218963Sats // lambda-expression. 219117700Smarkm InMessageExpressionRAIIObject InMessage(*this, true); 22055834Smdodd 22155834Smdodd BalancedDelimiterTracker T(*this, tok::l_square); 22255834Smdodd T.consumeOpen(); 22355834Smdodd SourceLocation StartLoc = T.getOpenLocation(); 22455834Smdodd 225117700Smarkm ExprResult Idx; 22655834Smdodd 22755834Smdodd // If Objective-C is enabled and this is a typename (class message 228963Sats // send) or send to 'super', parse this as a message send 229963Sats // expression. We handle C++ and C separately, since C++ requires 230963Sats // much more complicated parsing. 231963Sats if (getLangOpts().ObjC1 && getLangOpts().CPlusPlus) { 232963Sats // Send to 'super'. 233963Sats if (Tok.is(tok::identifier) && Tok.getIdentifierInfo() == Ident_super && 234963Sats NextToken().isNot(tok::period) && 235963Sats getCurScope()->isInObjcMethodScope()) { 2364435Sgibbs CheckArrayDesignatorSyntax(*this, StartLoc, Desig); 2374435Sgibbs return ParseAssignmentExprWithObjCMessageExprStart(StartLoc, 238963Sats ConsumeToken(), 2394435Sgibbs ParsedType(), 2404435Sgibbs 0); 2414435Sgibbs } 2424435Sgibbs 2434435Sgibbs // Parse the receiver, which is either a type or an expression. 2444435Sgibbs bool IsExpr; 2454435Sgibbs void *TypeOrExpr; 2464435Sgibbs if (ParseObjCXXMessageReceiver(IsExpr, TypeOrExpr)) { 247963Sats SkipUntil(tok::r_square); 248963Sats return ExprError(); 249963Sats } 250963Sats 251963Sats // If the receiver was a type, we have a class message; parse 252963Sats // the rest of it. 253963Sats if (!IsExpr) { 254121492Simp CheckArrayDesignatorSyntax(*this, StartLoc, Desig); 255121492Simp return ParseAssignmentExprWithObjCMessageExprStart(StartLoc, 256121492Simp SourceLocation(), 257121492Simp ParsedType::getFromOpaquePtr(TypeOrExpr), 258121492Simp 0); 259121492Simp } 260121492Simp 261121492Simp // If the receiver was an expression, we still don't know 262121492Simp // whether we have a message send or an array designator; just 263121492Simp // adopt the expression for further analysis below. 264121492Simp // FIXME: potentially-potentially evaluated expression above? 265121492Simp Idx = ExprResult(static_cast<Expr*>(TypeOrExpr)); 266121492Simp } else if (getLangOpts().ObjC1 && Tok.is(tok::identifier)) { 267963Sats IdentifierInfo *II = Tok.getIdentifierInfo(); 268963Sats SourceLocation IILoc = Tok.getLocation(); 269963Sats ParsedType ReceiverType; 270121492Simp // Three cases. This is a message send to a type: [type foo] 271121492Simp // This is a message send to super: [super foo] 272121492Simp // This is a message sent to an expr: [super.bar foo] 273121492Simp switch (Sema::ObjCMessageKind Kind 274963Sats = Actions.getObjCMessageKind(getCurScope(), II, IILoc, 275963Sats II == Ident_super, 276963Sats NextToken().is(tok::period), 277963Sats ReceiverType)) { 278963Sats case Sema::ObjCSuperMessage: 279963Sats case Sema::ObjCClassMessage: 280963Sats CheckArrayDesignatorSyntax(*this, StartLoc, Desig); 281963Sats if (Kind == Sema::ObjCSuperMessage) 282963Sats return ParseAssignmentExprWithObjCMessageExprStart(StartLoc, 283963Sats ConsumeToken(), 284963Sats ParsedType(), 285963Sats 0); 286963Sats ConsumeToken(); // the identifier 287963Sats if (!ReceiverType) { 288963Sats SkipUntil(tok::r_square); 289963Sats return ExprError(); 290963Sats } 291963Sats 292963Sats return ParseAssignmentExprWithObjCMessageExprStart(StartLoc, 293963Sats SourceLocation(), 294963Sats ReceiverType, 295963Sats 0); 296963Sats 297963Sats case Sema::ObjCInstanceMessage: 298963Sats // Fall through; we'll just parse the expression and 299963Sats // (possibly) treat this like an Objective-C message send 300963Sats // later. 301963Sats break; 302963Sats } 303963Sats } 304963Sats 305963Sats // Parse the index expression, if we haven't already gotten one 306963Sats // above (which can only happen in Objective-C++). 307117700Smarkm // Note that we parse this as an assignment expression, not a constant 3084435Sgibbs // expression (allowing *=, =, etc) to handle the objc case. Sema needs 3094435Sgibbs // to validate that the expression is a constant. 310963Sats // FIXME: We also need to tell Sema that we're in a 311963Sats // potentially-potentially evaluated context. 312121515Simp if (!Idx.get()) { 313121492Simp Idx = ParseAssignmentExpression(); 3147510Sjkh if (Idx.isInvalid()) { 3157510Sjkh SkipUntil(tok::r_square); 3167510Sjkh return move(Idx); 3177510Sjkh } 3187510Sjkh } 3197510Sjkh 3207510Sjkh // Given an expression, we could either have a designator (if the next 3217510Sjkh // tokens are '...' or ']' or an objc message send. If this is an objc 3227510Sjkh // message send, handle it now. An objc-message send is the start of 3237510Sjkh // an assignment-expression production. 3247510Sjkh if (getLangOpts().ObjC1 && Tok.isNot(tok::ellipsis) && 3257510Sjkh Tok.isNot(tok::r_square)) { 3267510Sjkh CheckArrayDesignatorSyntax(*this, Tok.getLocation(), Desig); 3277510Sjkh return ParseAssignmentExprWithObjCMessageExprStart(StartLoc, 328121492Simp SourceLocation(), 329121492Simp ParsedType(), 330121492Simp Idx.take()); 3317510Sjkh } 332963Sats 3338876Srgrimes // If this is a normal array designator, remember it. 3344435Sgibbs if (Tok.isNot(tok::ellipsis)) { 335963Sats Desig.AddDesignator(Designator::getArray(Idx.release(), StartLoc)); 336963Sats } else { 337963Sats // Handle the gnu array range extension. 338963Sats Diag(Tok, diag::ext_gnu_array_range); 339963Sats SourceLocation EllipsisLoc = ConsumeToken(); 340963Sats 341963Sats ExprResult RHS(ParseConstantExpression()); 342963Sats if (RHS.isInvalid()) { 343963Sats SkipUntil(tok::r_square); 344963Sats return move(RHS); 345963Sats } 346963Sats Desig.AddDesignator(Designator::getArrayRange(Idx.release(), 347963Sats RHS.release(), 348963Sats StartLoc, EllipsisLoc)); 3494435Sgibbs } 3504435Sgibbs 3514435Sgibbs T.consumeClose(); 3524435Sgibbs Desig.getDesignator(Desig.getNumDesignators() - 1).setRBracketLoc( 3534435Sgibbs T.getCloseLocation()); 3544435Sgibbs } 3554435Sgibbs 3564435Sgibbs // Okay, we're done with the designator sequence. We know that there must be 357963Sats // at least one designator, because the only case we can get into this method 358963Sats // without a designator is when we have an objc message send. That case is 3598876Srgrimes // handled and returned from above. 3604435Sgibbs assert(!Desig.empty() && "Designator is empty?"); 361963Sats 362963Sats // Handle a normal designator sequence end, which is an equal. 363963Sats if (Tok.is(tok::equal)) { 364963Sats SourceLocation EqualLoc = ConsumeToken(); 365963Sats return Actions.ActOnDesignatedInitializer(Desig, EqualLoc, false, 366963Sats ParseInitializer()); 367963Sats } 368963Sats 369963Sats // We read some number of designators and found something that isn't an = or 370963Sats // an initializer. If we have exactly one array designator, this 371963Sats // is the GNU 'designation: array-designator' extension. Otherwise, it is a 372963Sats // parse error. 373963Sats if (Desig.getNumDesignators() == 1 && 374963Sats (Desig.getDesignator(0).isArrayDesignator() || 375963Sats Desig.getDesignator(0).isArrayRangeDesignator())) { 376963Sats Diag(Tok, diag::ext_gnu_missing_equal_designator) 3774435Sgibbs << FixItHint::CreateInsertion(Tok.getLocation(), "= "); 378963Sats return Actions.ActOnDesignatedInitializer(Desig, Tok.getLocation(), 379963Sats true, ParseInitializer()); 380963Sats } 381963Sats 382963Sats Diag(Tok, diag::err_expected_equal_designator); 383963Sats return ExprError(); 3848876Srgrimes} 3854435Sgibbs 3864435Sgibbs 3874435Sgibbs/// ParseBraceInitializer - Called when parsing an initializer that has a 3884435Sgibbs/// leading open brace. 3894435Sgibbs/// 3904435Sgibbs/// initializer: [C99 6.7.8] 3914435Sgibbs/// '{' initializer-list '}' 3924435Sgibbs/// '{' initializer-list ',' '}' 3934435Sgibbs/// [GNU] '{' '}' 3944435Sgibbs/// 395121492Simp/// initializer-list: 3968876Srgrimes/// designation[opt] initializer ...[opt] 3974435Sgibbs/// initializer-list ',' designation[opt] initializer ...[opt] 3984435Sgibbs/// 3994435SgibbsExprResult Parser::ParseBraceInitializer() { 400121492Simp InMessageExpressionRAIIObject InMessage(*this, false); 401121492Simp 402121492Simp BalancedDelimiterTracker T(*this, tok::l_brace); 403121492Simp T.consumeOpen(); 4044435Sgibbs SourceLocation LBraceLoc = T.getOpenLocation(); 4054435Sgibbs 406963Sats /// InitExprs - This is the actual list of expressions contained in the 407963Sats /// initializer. 408117700Smarkm ExprVector InitExprs(Actions); 409117700Smarkm 410117700Smarkm if (Tok.is(tok::r_brace)) { 4114435Sgibbs // Empty initializers are a C++ feature and a GNU extension to C. 4124435Sgibbs if (!getLangOpts().CPlusPlus) 413963Sats Diag(LBraceLoc, diag::ext_gnu_empty_initializer); 414963Sats // Match the '}'. 415963Sats return Actions.ActOnInitList(LBraceLoc, MultiExprArg(Actions), 4164435Sgibbs ConsumeBrace()); 417963Sats } 418 419 bool InitExprsOk = true; 420 421 while (1) { 422 // Handle Microsoft __if_exists/if_not_exists if necessary. 423 if (getLangOpts().MicrosoftExt && (Tok.is(tok::kw___if_exists) || 424 Tok.is(tok::kw___if_not_exists))) { 425 if (ParseMicrosoftIfExistsBraceInitializer(InitExprs, InitExprsOk)) { 426 if (Tok.isNot(tok::comma)) break; 427 ConsumeToken(); 428 } 429 if (Tok.is(tok::r_brace)) break; 430 continue; 431 } 432 433 // Parse: designation[opt] initializer 434 435 // If we know that this cannot be a designation, just parse the nested 436 // initializer directly. 437 ExprResult SubElt; 438 if (MayBeDesignationStart()) 439 SubElt = ParseInitializerWithPotentialDesignator(); 440 else 441 SubElt = ParseInitializer(); 442 443 if (Tok.is(tok::ellipsis)) 444 SubElt = Actions.ActOnPackExpansion(SubElt.get(), ConsumeToken()); 445 446 // If we couldn't parse the subelement, bail out. 447 if (!SubElt.isInvalid()) { 448 InitExprs.push_back(SubElt.release()); 449 } else { 450 InitExprsOk = false; 451 452 // We have two ways to try to recover from this error: if the code looks 453 // grammatically ok (i.e. we have a comma coming up) try to continue 454 // parsing the rest of the initializer. This allows us to emit 455 // diagnostics for later elements that we find. If we don't see a comma, 456 // assume there is a parse error, and just skip to recover. 457 // FIXME: This comment doesn't sound right. If there is a r_brace 458 // immediately, it can't be an error, since there is no other way of 459 // leaving this loop except through this if. 460 if (Tok.isNot(tok::comma)) { 461 SkipUntil(tok::r_brace, false, true); 462 break; 463 } 464 } 465 466 // If we don't have a comma continued list, we're done. 467 if (Tok.isNot(tok::comma)) break; 468 469 // TODO: save comma locations if some client cares. 470 ConsumeToken(); 471 472 // Handle trailing comma. 473 if (Tok.is(tok::r_brace)) break; 474 } 475 476 bool closed = !T.consumeClose(); 477 478 if (InitExprsOk && closed) 479 return Actions.ActOnInitList(LBraceLoc, move_arg(InitExprs), 480 T.getCloseLocation()); 481 482 return ExprError(); // an error occurred. 483} 484 485 486// Return true if a comma (or closing brace) is necessary after the 487// __if_exists/if_not_exists statement. 488bool Parser::ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs, 489 bool &InitExprsOk) { 490 bool trailingComma = false; 491 IfExistsCondition Result; 492 if (ParseMicrosoftIfExistsCondition(Result)) 493 return false; 494 495 BalancedDelimiterTracker Braces(*this, tok::l_brace); 496 if (Braces.consumeOpen()) { 497 Diag(Tok, diag::err_expected_lbrace); 498 return false; 499 } 500 501 switch (Result.Behavior) { 502 case IEB_Parse: 503 // Parse the declarations below. 504 break; 505 506 case IEB_Dependent: 507 Diag(Result.KeywordLoc, diag::warn_microsoft_dependent_exists) 508 << Result.IsIfExists; 509 // Fall through to skip. 510 511 case IEB_Skip: 512 Braces.skipToEnd(); 513 return false; 514 } 515 516 while (Tok.isNot(tok::eof)) { 517 trailingComma = false; 518 // If we know that this cannot be a designation, just parse the nested 519 // initializer directly. 520 ExprResult SubElt; 521 if (MayBeDesignationStart()) 522 SubElt = ParseInitializerWithPotentialDesignator(); 523 else 524 SubElt = ParseInitializer(); 525 526 if (Tok.is(tok::ellipsis)) 527 SubElt = Actions.ActOnPackExpansion(SubElt.get(), ConsumeToken()); 528 529 // If we couldn't parse the subelement, bail out. 530 if (!SubElt.isInvalid()) 531 InitExprs.push_back(SubElt.release()); 532 else 533 InitExprsOk = false; 534 535 if (Tok.is(tok::comma)) { 536 ConsumeToken(); 537 trailingComma = true; 538 } 539 540 if (Tok.is(tok::r_brace)) 541 break; 542 } 543 544 Braces.consumeClose(); 545 546 return !trailingComma; 547} 548