[cfe-dev] Decl::dump() doesn't print/visit(?) some statements (such as: bool x = true)

Douglas Gregor dgregor at apple.com
Mon Jun 20 08:29:09 PDT 2011


On Jun 19, 2011, at 10:06 PM, sirinda wrote:

> Hi all,
> 
> I have MyConsumer class which implemented ASTConsumer and inherited from
> RecursiveASTVisitor to instrument some code at some point in a program. I
> have noticed that some statements are not visited.
> 
> So I use Decl::dump() in TraverseDecl(Decl *D) to see all declaration detail
> especially function declaration. 
> 
> My test program look like this : (I omit the main function here)
> 
> void bubble_sort(int* array, int size) {
> 	 bool continue_flag = true;
> 	 do {
> 		continue_flag = false;
> 		for (int i = 0; i < size - 1; i++) {
> 			if (array[i] > array [i+1]){
> 		             int temp = array[i] ;
> 			     array[i] = array[i+1] ;
> 			     array[i+1]  = temp;
> 			     continue_flag = true;
> 			}
> 		}
> 	} while (continue_flag);
> }
> 
> What I got from Decl::dump() is 
> 
> void bubble_sort(int *array, int size) {
> 
> }
> 
> 
> But when I changed the type from bool to int, Decl::dump() printed all
> statements. 
> My test program is compiled just fine using g++. 
> 
> What does that mean? 

dump() is a debugging aid that is known to be incomplete and incorrect. It gets improved as needed, and patches are always welcome.

	- Doug



More information about the cfe-dev mailing list