[cfe-dev] Rewriter object is not resetting correctly
victor
pedretti_86 at hotmail.com
Mon Jun 9 10:37:36 PDT 2014
Hello,
I'm having a strange problem with my clang tool and I would like to report it because maybe I'm doing something wrong, but it might be a bug.
My tool simply takes a source file, performs a change in the code and saves the new version. The program is under the version control system git and the new version is stored in a new git branch. This process is done a finite number of times and I reset the Rewriter object between a version and the next one (so that the change is not present in the rest of versions) in the following way:
Rewrite = Rewriter();
Rewrite.setSourceMgr(Context->getSourceManager(), Context->getLangOpts());
Everything seemed to work right, but the other day I tested my tool with a program and I found something really strange. The problem is that the first and only the first change performed in the code remains in all the following versiones. For instance, if I insert a comment in each of the lines:
Original:
int method(int a){
int b = a + 1;
return b;
}
First version:
/*1*/ int method(int a){
int b = a + 1;
return b;
}
Second version:
/*1*/ int method(int a){
/*2*/ int b = a + 1;
return b;
}
Third version:
/*1*/ int method(int a){
int b = a + 1;
/*3*/ return b;
}
The problem is that the comment "/*1*/" should be only in the first version, but not in the rest. As you can see, "/*2*/" is not in the third version and that is the expected.
I have tried a lot of things, but nothing seems to solve this issue that only appears in this and other program that I tested today.
What could be happening here?
Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140609/afd8faa2/attachment.html>
More information about the cfe-dev
mailing list