Calling a function call in c code using Clang

I want to write a program that decomposes expressions (in C code) in which they have function calls and extracts each function call to a variable. For example:

x = A() + B();

should be changed to:

a = A();
b = B();
x = a + b;

      

I am writing it using Clang and RecursiveASTVisitor. Here is my solution. First, I have to search for all functions and declare a variable for each one in the first of my main block, which contains all the calls. Then look for binary operations that have a function call on both sides. Then, extract the function calls and use variables instead. Since I'm new to this, I don't know if there is a better way to do this or does this solution work at all?

+3
c clang refactoring abstract-syntax-tree libtooling


source to share


No one has answered this question yet

Check out similar questions:

2847
Improve SQLite performance per second per second?
1470
What ":-!!" in C code?
1119
How do function pointers work in C?
590
How to reach the theoretical maximum of 4 FLOPs per cycle?
438
What REALLY happens when you are not free after malloc?
nineteen
It is not possible to declare an operator inside a function. Clang or spec error?
2
How do I extract a control flow diagram from source using Clang?
2
CLang Libtooling: choosing data type of a variable inside clang :: VarDecl, clang :: FieldDecl or clang :: ParmVarDecl
1
get variables in real time in the refactoring tool
0
Clang IfStmt with fast binary operator in condition



All Articles
Loading...
X
Show
Funny
Dev
Pics