Wrapping if and for body with brackets

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Wrapping if and for body with brackets

Adam Cieszkiel via cfe-dev

Hi,
I want to wrap body of is statement inside a bracket.
Ex if()a=b; ---> if (){a=b}
I am doing with the help of
if(IfStmt *ifStmt = dyn_cast<IfStmt>(st)){
                rewriter.InsertTextBefore(ifStmt->getThen()->getLocStart(),"{\n");
                rewriter.InsertTextAfterToken(ifStmt->getThen()->getLocEnd(),";\n}//");
                if(ifStmt->getElse() != NULL){
                    rewriter.InsertTextBefore(ifStmt->getElseLoc(),"\n");
                    rewriter.InsertTextBefore(ifStmt->getElse()->getLocStart(),"{\n");
                    rewriter.InsertTextAfterToken(ifStmt->getElse()->getLocEnd(),";\n}//");
                }

But it is giving me weird answer like closing bracket missing or on
wrapping when if has single line body. Can someone inform me where I am
doing wrong.

--
Thanks and Regards
Awanish Pandey
PhD, CSE
IIT Kanpur

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Loading...