I have the source code that looks like this:
void update(); void update() { }
I am trying to parse this code with clang and change 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 clang classes. In the function I wrote as shown below
MyRecursiveASTVisitor::VisitFunctionDecl(FunctionDecl *f)
FunctionDecl has a setParams () method that I could use. I would have to create parameters using 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'm not sure what the rest should be.
How can I create types and also assign values ββto them in clang? Types do not have to be inlined and can be similar to the added (v4sf) in the converted source code.
Is this a way (using clang methods) to do the conversion, or can I use Rewriter.InsertText () to add parameters?
source share