I have source code which looks like this,
void update();
void update()
{
}
Iam trying to parse this code with clang and modify the code to this.
typedef float v4sf attribute ((vector_size(16)));
void update(v4sf& v1, v4sf& v2);
void update(v4sf& v1, v4sf& v2)
{
}
I looked at the Rewriter classes of clang. In the function which i wrote as shown below,
MyRecursiveASTVisitor::VisitFunctionDecl(FunctionDecl *f)
FunctionDecl has setParams() method which i could use. I would have to create params with this method.
static ParmVarDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation StartLoc,
SourceLocation IdLoc, IdentifierInfo *Id,
QualType T, TypeSourceInfo *TInfo,
StorageClass S, StorageClass SCAsWritten,
Expr *DefArg);
The first four arguments to the create function can be obtained from FunctionDecl. I am not sure what the rest of them have to be.
How do i create types and also assign values to them in clang? The types need not be builtin and could be the like the one added(v4sf) in transformed source code.
Is this way(using clang methods) to do transformations or can i use Rewriter.InsertText() to add the parameters?