@@ -101,7 +101,7 @@ TokenSequence Definition::Tokenize(const std::vector<std::string> &argNames,
101
101
continue ;
102
102
}
103
103
}
104
- result.Put (token, firstToken + j, 1 );
104
+ result.AppendRange (token, firstToken + j, 1 );
105
105
}
106
106
return result;
107
107
}
@@ -170,7 +170,7 @@ static TokenSequence TokenPasting(TokenSequence &&text) {
170
170
}
171
171
} else if (pasting && text.TokenAt (j).IsBlank ()) {
172
172
} else {
173
- result.Put (text, j, 1 );
173
+ result.AppendRange (text, j, 1 );
174
174
pasting = false ;
175
175
}
176
176
}
@@ -223,7 +223,7 @@ TokenSequence Definition::Apply(const std::vector<TokenSequence> &args,
223
223
CHECK (resultSize > 0 &&
224
224
result.TokenAt (resultSize - 1 ) == replacement_.TokenAt (prev - 1 ));
225
225
result.pop_back ();
226
- result.Put (Stringify (args[index], prescanner.allSources ()));
226
+ result.CopyAll (Stringify (args[index], prescanner.allSources ()));
227
227
} else {
228
228
const TokenSequence *arg{&args[index]};
229
229
std::optional<TokenSequence> replaced;
@@ -243,7 +243,7 @@ TokenSequence Definition::Apply(const std::vector<TokenSequence> &args,
243
243
}
244
244
}
245
245
}
246
- result.Put (DEREF (arg));
246
+ result.CopyAll (DEREF (arg));
247
247
}
248
248
} else if (bytes == 11 && isVariadic_ &&
249
249
token.ToString () == " __VA_ARGS__" ) {
@@ -254,7 +254,7 @@ TokenSequence Definition::Apply(const std::vector<TokenSequence> &args,
254
254
if (k > argumentCount ()) {
255
255
result.Put (" ," s, commaProvenance);
256
256
}
257
- result.Put (args[k]);
257
+ result.CopyAll (args[k]);
258
258
}
259
259
} else if (bytes == 10 && isVariadic_ && token.ToString () == " __VA_OPT__" &&
260
260
j + 2 < tokens && replacement_.TokenAt (j + 1 ).OnlyNonBlank () == ' (' &&
@@ -274,7 +274,7 @@ TokenSequence Definition::Apply(const std::vector<TokenSequence> &args,
274
274
}
275
275
}
276
276
}
277
- result.Put (replacement_, j);
277
+ result.AppendRange (replacement_, j);
278
278
}
279
279
}
280
280
return TokenPasting (std::move (result));
@@ -338,18 +338,18 @@ std::optional<TokenSequence> Preprocessor::MacroReplacement(
338
338
inIfExpression](std::size_t after, const TokenSequence &replacement,
339
339
std::size_t pFLMOffset) {
340
340
if (after < input.SizeInTokens ()) {
341
- result.Put (replacement, 0 , pFLMOffset);
341
+ result.AppendRange (replacement, 0 , pFLMOffset);
342
342
TokenSequence suffix;
343
- suffix.Put (
343
+ suffix.AppendRange (
344
344
replacement, pFLMOffset, replacement.SizeInTokens () - pFLMOffset);
345
- suffix.Put (input, after, input.SizeInTokens () - after);
345
+ suffix.AppendRange (input, after, input.SizeInTokens () - after);
346
346
auto further{ReplaceMacros (
347
347
suffix, prescanner, partialFunctionLikeMacro, inIfExpression)};
348
348
if (partialFunctionLikeMacro && *partialFunctionLikeMacro) {
349
349
// still not closed
350
350
**partialFunctionLikeMacro += result.SizeInTokens ();
351
351
}
352
- result.Put (further);
352
+ result.CopyAll (further);
353
353
return true ;
354
354
} else {
355
355
if (partialFunctionLikeMacro) {
@@ -362,7 +362,7 @@ std::optional<TokenSequence> Preprocessor::MacroReplacement(
362
362
for (; j < tokens; ++j) {
363
363
CharBlock token{input.TokenAt (j)};
364
364
if (token.IsBlank () || !IsLegalIdentifierStart (token[0 ])) {
365
- result.Put (input, j);
365
+ result.AppendRange (input, j);
366
366
continue ;
367
367
}
368
368
// Process identifier in replacement text.
@@ -388,12 +388,12 @@ std::optional<TokenSequence> Preprocessor::MacroReplacement(
388
388
}
389
389
}
390
390
if (it == definitions_.end ()) {
391
- result.Put (input, j);
391
+ result.AppendRange (input, j);
392
392
continue ;
393
393
}
394
394
Definition *def{&it->second };
395
395
if (def->isDisabled ()) {
396
- result.Put (input, j);
396
+ result.AppendRange (input, j);
397
397
continue ;
398
398
}
399
399
if (!def->isFunctionLike ()) {
@@ -444,7 +444,7 @@ std::optional<TokenSequence> Preprocessor::MacroReplacement(
444
444
ProvenanceRange use{input.GetTokenProvenanceRange (j)};
445
445
ProvenanceRange newRange{
446
446
allSources_.AddMacroCall (from, use, replaced.ToString ())};
447
- result.Put (replaced, newRange);
447
+ result.CopyWithProvenance (replaced, newRange);
448
448
}
449
449
} else {
450
450
// Possible function-like macro call. Skip spaces and newlines to see
@@ -461,10 +461,10 @@ std::optional<TokenSequence> Preprocessor::MacroReplacement(
461
461
if (!leftParen) {
462
462
if (partialFunctionLikeMacro) {
463
463
*partialFunctionLikeMacro = result.SizeInTokens ();
464
- result.Put (input, j, tokens - j);
464
+ result.AppendRange (input, j, tokens - j);
465
465
return result;
466
466
} else {
467
- result.Put (input, j);
467
+ result.AppendRange (input, j);
468
468
continue ;
469
469
}
470
470
}
@@ -491,11 +491,11 @@ std::optional<TokenSequence> Preprocessor::MacroReplacement(
491
491
}
492
492
if (k >= tokens && partialFunctionLikeMacro) {
493
493
*partialFunctionLikeMacro = result.SizeInTokens ();
494
- result.Put (input, j, tokens - j);
494
+ result.AppendRange (input, j, tokens - j);
495
495
return result;
496
496
} else if (k >= tokens || argStart.size () < def->argumentCount () ||
497
497
(argStart.size () > def->argumentCount () && !def->isVariadic ())) {
498
- result.Put (input, j);
498
+ result.AppendRange (input, j);
499
499
continue ;
500
500
}
501
501
std::vector<TokenSequence> args;
@@ -520,7 +520,7 @@ std::optional<TokenSequence> Preprocessor::MacroReplacement(
520
520
ProvenanceRange use{input.GetIntervalProvenanceRange (j, k - j)};
521
521
ProvenanceRange newRange{
522
522
allSources_.AddMacroCall (from, use, replaced.ToString ())};
523
- result.Put (replaced, newRange);
523
+ result.CopyWithProvenance (replaced, newRange);
524
524
}
525
525
j = k; // advance to the terminal ')'
526
526
}
0 commit comments