[PATCH] cpp11-migrate: Write header replacements to disk
Guillaume Papin
guillaume.papin at epitech.eu
Tue Jul 16 02:34:04 PDT 2013
I will explain my example a bit further maybe I wasn't understood. The orders of a "batch" of replacements, returned by a transform is not important, `tooling::applyAllReplacements()` (or some other tooling functions) handle that correctly. The issue for me is that nothing seems to enforce an order for the transforms.
If I take my example again but explain more in details:
The YAML format I used is hypothetical and I'm not sure the LoopConvert/UseAuto transforms work like this.
Given:
for (std::vector<int>::iterator I = V.begin(), E = V.end(); I != E; ++I)
std::cout << *I << std::endl;
First LoopConvert is applied:
```
- TransformID: LoopConvertTransform
Offset: 5
Length: 66
ReplacementText: "auto &elem : V"
- TransformID: LoopConvertTransform
Offset: 90
Length: 2
ReplacementText: "elem"
```
Then UseAuto is applied with the given content:
for (auto &elem : V)
std::cout << elem << std::endl;
This is the final content, UseAuto doesn't generate any replacement.
-----------------------------------------------------------------------------
Now the YAML if the replacements are done in the reversed order (first UseAuto, then LoopConvert).
for (std::vector<int>::iterator I = V.begin(), E = V.end(); I != E; ++I)
std::cout << *I << std::endl;
UseAuto replacements first:
```
- TransformID: UseAutoTransform
Offset: 5
Length: 26
ReplacementText: "auto"
```
The iterator is transformed and we have the following input for loop convert:
for (auto I = V.begin(), E = V.end(); I != E; ++I)
std::cout << *I << std::endl;
LoopConvert YAML is:
```
- TransformID: LoopConvertTransform
Offset: 5
Length: 44
ReplacementText: "for (auto &elem : V)"
- TransformID: LoopConvertTransform
Offset: 68
Length: 2
ReplacementText: "elem"
```
As you can see the YAML is different. IMHO the order should be enforced in some way (maybe it's just a matter of numbering the "batches of replacements" produced by a transform).
http://llvm-reviews.chandlerc.com/D1142
More information about the cfe-commits
mailing list