[cfe-dev] Changing the access specifier of a FieldDecl
Pedro Delgado Perez
pedro.delgado at uca.es
Wed Dec 4 02:14:33 PST 2013
I've been quite a while trying to change the access specifier of a FieldDecl. I thought doing this wouldn't be difficult as I found the method setAccess() in class Decl.
For instance, I tried:
But it didn't work. I suppose I can't change the access specifier of an entire block of members, but maybe I was expecting that field with a new access specifier out of the block in which it was. I tried then to create a copy of the field and add a new declaration in the recordDecl with addDecl:
This didn't suppose any change and the execution "froze" after finding the first field. Maybe, in this cases when no text is removed or inserted, I am not using correctly the class Rewrite:
const RewriteBuffer *RewriteBuf = Rewrite.getRewriteBufferFor(FullLocation.getFileID());
Finally, I tried to directly insert the field as text:
string("\npublic:\n"+field->getType().getAsString()+" "+ field->getNameAsString()+";\n");
But then I realize that I didn't know how to keep the modifiers (const, mutable...) of the field. I have found "Attrs" in Decl, but I'm not pretty sure about what is exactly an "Attr" and how can I get these "Attrs" as strings.
As you can see, I am a bit lost and I need a bit of help to clarify all this.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev