[cfe-users] Finding of functions and inserting code

2015-12-02 Thread Radim Sojka via cfe-users

Hello,

I'd like to ask you if it is possible to find the lines of my code where 
the specific functions is called and insert some code around function's 
block.


Example of code:

10: some code
11: foo()
12: some code/
/

Example of output:

10: some code
11: inserted code
12: foo()
13: inserted code
14: some code

foo() was called on line 11




Is it possible with Clang?

Thank you for your answers!
Radim

___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


[cfe-users] libclang get AST tree of macro extension

2015-12-02 Thread Laurent Carlier via cfe-users
Hello,

I'm currently busy with using libclang library.

My goal is to parse code that contains macro with parameters and to get the
type of the macro parameters in order to make syntax coloration.

If we consider the following piece of code

#define MACRO(X) X
typedef struct{
  int a;} aType;

aType data;
int var = MACRO(data.a);

My goal is to be able to color the field a of the structure aType on the
line int var = MACRO(data.a). I.e. I would like to get the line, column and
type whenever I'm getting a cursor over the field a of data variable.

The problem is that whenever I'm getting the cursor on the position of
character a, its type is CXCursor_MacroExpansion. I've already tried to get
the referenced cursor (via clang_getCursorReferenced) but then I'm getting
a cursor type CXCursor_MacroDefinition.

I've also already tried to visit the child via clang_visitChildren but this
returning the cursor itself as well, so it is not useful.

If I could get a cursor with type CXCursor_MemberRefExpr out of my cursor
with type CXCusor_MacroExtension I would have what I need.

Does anyone have an idea how to actually get the info of expanded code iso
getting CXCursor_MacroExpansion, whenever cursor is over a macro expansion?

Thanks a lot for your time and help.

Kind regards,

Laurent
___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users