How to determine the dimensions of a ConstantArrayType

Hi all,

I am trying to get the number of dimensions of a ConstantArrayType.

My code is the follwing:

if (var->getType().getTypePtr()->isArrayType()) //if the variable declaration is an array type, gets its dimensions

const ConstantArrayType *array = astContext->getAsConstantArrayType(var->getType());
string type;
int i = 1; //dimensions counter
type = array->getElementType().getAsString();
const ConstantArrayType *array = astContext->getAsConstantArrayType(array->getElementType());
cout << type << " ";
for (int k = 0; k < i; k++)
cout << "[number] ";
cout << endl;

What I want to achieve is when I find a declaration in the source code am analysing for example

int [111] [222] [333]

I want to print it like this

int [number] [number] [number]

I am having a hard time finding the number of dimensions of the declared array.
I dont know automatically keep extracting the dimensions of a multiimensional array as 1-dimensional arrays. The problem is inside the do-while loop.

Please help me …