[cfe-dev] condition expression for while loops - not printing using

rks rks at cse.iitb.ac.in
Fri Mar 15 08:14:49 PDT 2013


Hi,

We are trying to dump condition expression for while loop using clang 
Visit methods.

It works fine for normal while loops. It doesn't work and crashes with 
stack dump for following code:

int main(void)
{
   int a ;

   {
   {
   while (1) {
     while_continue: ;
     if (! a) {
       goto while_break;
     }
     if (a > 20) {
       a ++;
       goto while_break;
     } else {
       goto while_break;
     }
   }
   while_break: ;
   }
   return (0);
}
}

I am unable to figure out why it doesn't print condition.

I am using this code:

WhileStmt* While = cast<WhileStmt>(stmt);
const Expr* cond = While->getCond();

where stmt is pointer to clang::Stmt object.

We are getting clang::CFGStmt object by iterating over statements in 
basic block using CFG Block iterators.

- Rajendra



More information about the cfe-dev mailing list