Dear All,
I have a question
How could I use WhileStmt class
in Stmt.h
http://clang.llvm.org/doxygen/Stmt_8h_source.html
to implement while loop
like while(i==1){}
that is required to be inserted
For example, Convert x++; y++; to x++; while(i=1){} y++;
from the class’s constructor:
WhileStmt(ASTContext &C, VarDecl *Var, Expr *cond, Stmt *body,SourceLocation WL);
//I know C --> 1
//Var--> i
//cond --> =
//body --> NOP
//WL --> ??
but how to implement these terms in LLVM pass? and what’s the SourceLocation?
Thanks
Rasha Omar wrote:
Dear All,
I have a question
How could I use |WhileStmt class| in Stmt.h
http://clang.llvm.org/doxygen/Stmt_8h_source.html
to implement |while loop| like |while(i==1){}| that is required to be
inserted
For example, Convert x++; y++; to x++; while(i=1){} y++;
from the class's constructor:
>WhileStmt(ASTContext &C, VarDecl *Var, Expr *cond, Stmt *body,SourceLocation WL);
//I know C --> 1
//Var--> i
//cond --> =
//body --> NOP
//WL --> ??|
but how to implement these terms in LLVM pass? and what's the
SourceLocation?
Do you actually mean LLVM pass? Or are you working inside clang (for example, on a source code rewriter)? If so, email cfe-dev instead.
Nick
No, I need to use it in LLVM pass. Could it work?
Rasha Omar wrote:
No, I need to use it in LLVM pass. Could it work?
No. The language available at llvm-time is the one in llvm.org/docs/LangRef.html which doesn't have a while statement. For one obvious example, how would this work if the input language wasn't C/C++ to begin with?
If you absolutely need to do this for a non-production-quality project (ie., research project or other one-off), you can jam the WhileStmt pointer value as an integer into a metadata node when doing IRGen from clang, and reinterpret it back on the llvm side. We will not accept patches which do this sort of thing, and this is very much warranty void territory. Your generated IR will not work if you try to run llvm tools outside the clang process.
Nick