Author Topic: small bug in Rename symbols command  (Read 5694 times)

Offline frithjofh

  • Regular
  • ***
  • Posts: 376
small bug in Rename symbols command
« on: May 11, 2011, 10:59:38 am »
Hello everybody,

I think there is a small bug in the "Rename symbol" command. If the name of a class (or any other symbol, but that is a little less likely) is the same as the name of the header file, than the include directives of that header file get changed when you use the command to change the class name. I did the test with a class name I wanted to change to begin with a capital letter and the execution of the command changed the file name in the include directives accordingly. Reproducible and always.

Another related bug which I can't reproduce always (it seems to happen intermittently) is that when changing the class name to begin with a capital letter it gets changed alright, but the change is not done in the second mentioning of the class in it's constructors. The original code:

Code
surface::surface() {}

gets changed to

Code
Surface::surface() {}

Regards and greetings from Asturias

frithjofh
architect with some spare time  -  c::b compiled from last svn  -   openSuSE leap x86_64  -  AMD FX-4100

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: small bug in Rename symbols command
« Reply #1 on: May 11, 2011, 02:50:15 pm »
thanks for the bug report!!!

first issue:
Quote
I think there is a small bug in the "Rename symbol" command. If the name of a class (or any other symbol, but that is a little less likely) is the same as the name of the header file, than the include directives of that header file get changed when you use the command to change the class name. I did the test with a class name I wanted to change to begin with a capital letter and the execution of the command changed the file name in the include directives accordingly. Reproducible and always.
Ok, from the internal algorithm I know, I think it is definitely a bug. For example:
Code
#include "Apple.h"
#include <Apple.h>
class Apple
{
};
Apple a;
Rename "Apple" to "Orange" will change four occurrences in the code snippet.
This can be simply filter out a preprocessor line. Note "Rename" feature is not 100% correct unless we do a full parsing and walk on the AST (like a compiler did). Currently implementation is very limited.

Issue 2:
Maybe we can add a special case of handling constructors renaming. I don't know much about the reason. :D, hope i will get some time to look into it.

PS:
My current interest was doing a quex based parser, see:
http://code.google.com/p/quexparser/
and
http://code.google.com/p/quexparser/source/browse/trunk/parser.cbp
 :)




« Last Edit: May 11, 2011, 02:52:07 pm by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.