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

Sirinda sxp969 at psu.edu
Sun Jun 19 22:06:23 PDT 2011


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? Clang doesn't know bool keyword (very unlikely)? 
It also ignore statements like printf, cout too. 

Here is my command to build the executable: 

++ inst.cpp -g -o tc `$LLVM/Release+Profile+Asserts/bin/llvm-config
--cxxflags` -I$LLVM/tools/clang/include/ -lclangFrontendTool -lclangFrontend
-lclangDriver -lclangSerialization -lclangCodeGen -lclangParse -lclangSema
-lclangAnalysis -lclangIndex -lclangRewrite -lclangAST -lclangLex
-lclangBasic `$LLVM/Release+Profile+Asserts/bin/llvm-config --ldflags
--libs` -I/usr/local/include -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS

Do I miss something? 

-Sirinda 


--
View this message in context: http://clang-developers.42468.n3.nabble.com/Decl-dump-doesn-t-print-visit-some-statements-such-as-bool-x-true-tp3084860p3084860.html
Sent from the Clang Developers mailing list archive at Nabble.com.



More information about the cfe-dev mailing list