Author: Timm Bäder Date: 2023-04-20T11:51:05+02:00 New Revision: 9bbe25eca534b0627e03749437713183452ec8c5
URL: https://github.com/llvm/llvm-project/commit/9bbe25eca534b0627e03749437713183452ec8c5 DIFF: https://github.com/llvm/llvm-project/commit/9bbe25eca534b0627e03749437713183452ec8c5.diff LOG: [clang][Lex][NFC] Use a range for loop in StringLiteralParser Added: Modified: clang/lib/Lex/LiteralSupport.cpp Removed: ################################################################################ diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp index 3efecc709334c..9cc0215fb6250 100644 --- a/clang/lib/Lex/LiteralSupport.cpp +++ b/clang/lib/Lex/LiteralSupport.cpp @@ -1867,28 +1867,27 @@ void StringLiteralParser::init(ArrayRef<Token> StringToks){ // Implement Translation Phase #6: concatenation of string literals /// (C99 5.1.1.2p1). The common case is only one string fragment. - for (unsigned i = 1; i != StringToks.size(); ++i) { - if (StringToks[i].getLength() < 2) - return DiagnoseLexingError(StringToks[i].getLocation()); + for (const Token &Tok : StringToks) { + if (Tok.getLength() < 2) + return DiagnoseLexingError(Tok.getLocation()); // The string could be shorter than this if it needs cleaning, but this is a // reasonable bound, which is all we need. - assert(StringToks[i].getLength() >= 2 && "literal token is invalid!"); - SizeBound += StringToks[i].getLength()-2; // -2 for "". + assert(Tok.getLength() >= 2 && "literal token is invalid!"); + SizeBound += Tok.getLength() - 2; // -2 for "". // Remember maximum string piece length. - if (StringToks[i].getLength() > MaxTokenLength) - MaxTokenLength = StringToks[i].getLength(); + if (Tok.getLength() > MaxTokenLength) + MaxTokenLength = Tok.getLength(); // Remember if we see any wide or utf-8/16/32 strings. // Also check for illegal concatenations. - if (StringToks[i].isNot(Kind) && StringToks[i].isNot(tok::string_literal)) { + if (Tok.isNot(Kind) && Tok.isNot(tok::string_literal)) { if (isOrdinary()) { - Kind = StringToks[i].getKind(); + Kind = Tok.getKind(); } else { if (Diags) - Diags->Report(StringToks[i].getLocation(), - diag::err_unsupported_string_concat); + Diags->Report(Tok.getLocation(), diag::err_unsupported_string_concat); hadError = true; } } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits