// 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;
}
}