[cfe-users] Is Clang my solution?

Pedro Delgado Perez pedro.delgadoperez at mail.uca.es
Fri Dec 28 12:54:39 PST 2012


 
Hello,

I don't need any information about the plugin, but I would like to know if Clang is what I need and I wonder if you could help me because I'm a bit lost. Well, what I need is to parser a C++ program in order to ger some information about the code and, after that, to change the code regarding that information collected. For instance, if I have this function:
1 int addition (int a, int b){
2    return a + b;
3 };
I would need to know that there is a plus sign (+) and where it is located in the code. So i would need the compiler told me there is a + sign in the second line.
Once i have that information,the next step would be to parse the code again to turn that + sign into another sign, for instance, the multiplication sign:
int addition (int a, int b){
    return a * b;
};
Could I do what i want with Clang? I don't want to write a whole parser for C++, that would be really though and I'm looking for a solution. I would need to collect more information apart from arithmetic operators such as all the constant values or even the inheritance hierarchy among classes if a program uses object-oriented features.
I hope you could lend me a hand. Thanks in advance.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20121228/0dc27be1/attachment.html>


More information about the cfe-users mailing list