@@ -264,7 +264,7 @@ struct Parser::ScopedContextEntry {
264
264
Parser *parser;
265
265
266
266
ScopedContextEntry (Parser *parser, MatcherCtor c) : parser(parser) {
267
- parser->contextStack .push_back (std::make_pair ( c, 0u ) );
267
+ parser->contextStack .push_back ({ c, 0u } );
268
268
}
269
269
270
270
~ScopedContextEntry () { parser->contextStack .pop_back (); }
@@ -273,8 +273,8 @@ struct Parser::ScopedContextEntry {
273
273
};
274
274
275
275
// Parse and validate expressions starting with an identifier.
276
- // This function can parse named values and matchers. In case of failure it will
277
- // try to determine the user's intent to give an appropriate error message.
276
+ // This function can parse named values and matchers. In case of failure, it
277
+ // will try to determine the user's intent to give an appropriate error message.
278
278
bool Parser::parseIdentifierPrefixImpl (VariantValue *value) {
279
279
const TokenInfo nameToken = tokenizer->consumeNextToken ();
280
280
@@ -297,7 +297,7 @@ bool Parser::parseIdentifierPrefixImpl(VariantValue *value) {
297
297
}
298
298
299
299
// If the syntax is correct and the name is not a matcher either, report
300
- // unknown named value.
300
+ // an unknown named value.
301
301
if ((tokenizer->nextTokenKind () == TokenInfo::TK_Comma ||
302
302
tokenizer->nextTokenKind () == TokenInfo::TK_CloseParen ||
303
303
tokenizer->nextTokenKind () == TokenInfo::TK_NewLine ||
@@ -495,12 +495,13 @@ void Parser::addCompletion(const TokenInfo &compToken,
495
495
std::vector<MatcherCompletion>
496
496
Parser::getNamedValueCompletions (ArrayRef<ArgKind> acceptedTypes) {
497
497
if (!namedValues)
498
- return std::vector<MatcherCompletion>();
498
+ return {};
499
+
499
500
std::vector<MatcherCompletion> result;
500
501
for (const auto &entry : *namedValues) {
501
- std::string Decl =
502
+ std::string decl =
502
503
(entry.getValue ().getTypeAsString () + " " + entry.getKey ()).str ();
503
- result.emplace_back (entry.getKey (), Decl );
504
+ result.emplace_back (entry.getKey (), decl );
504
505
}
505
506
return result;
506
507
}
@@ -511,10 +512,8 @@ void Parser::addExpressionCompletions() {
511
512
512
513
// We cannot complete code if there is an invalid element on the context
513
514
// stack.
514
- for (ContextStackTy::iterator I = contextStack.begin (),
515
- E = contextStack.end ();
516
- I != E; ++I) {
517
- if (!I->first )
515
+ for (const auto &entry : contextStack) {
516
+ if (!entry.first )
518
517
return ;
519
518
}
520
519
@@ -607,10 +606,12 @@ bool Parser::parseExpression(llvm::StringRef &code, Sema *sema,
607
606
const NamedValueMap *namedValues,
608
607
VariantValue *value, Diagnostics *error) {
609
608
CodeTokenizer tokenizer (code, error);
610
- if (!Parser (&tokenizer, sema, namedValues, error).parseExpressionImpl (value))
609
+ Parser parser (&tokenizer, sema, namedValues, error);
610
+ if (!parser.parseExpressionImpl (value))
611
611
return false ;
612
- auto NT = tokenizer.peekNextToken ();
613
- if (NT.kind != TokenInfo::TK_Eof && NT.kind != TokenInfo::TK_NewLine) {
612
+ auto nextToken = tokenizer.peekNextToken ();
613
+ if (nextToken.kind != TokenInfo::TK_Eof &&
614
+ nextToken.kind != TokenInfo::TK_NewLine) {
614
615
error->addError (tokenizer.peekNextToken ().range ,
615
616
error->ET_ParserTrailingCode );
616
617
return false ;
@@ -623,11 +624,11 @@ Parser::completeExpression(llvm::StringRef &code, unsigned completionOffset,
623
624
Sema *sema, const NamedValueMap *namedValues) {
624
625
Diagnostics error;
625
626
CodeTokenizer tokenizer (code, &error, completionOffset);
626
- Parser P (&tokenizer, sema, namedValues, &error);
627
+ Parser parser (&tokenizer, sema, namedValues, &error);
627
628
VariantValue dummy;
628
- P .parseExpressionImpl (&dummy);
629
+ parser .parseExpressionImpl (&dummy);
629
630
630
- return P .completions ;
631
+ return parser .completions ;
631
632
}
632
633
633
634
std::optional<DynMatcher>
0 commit comments