<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Hi all,</p>
<p><br>
</p>
<p>I am trying to get the number of dimensions of a ConstantArrayType.</p>
<p>My code is the follwing:</p>
<p><br>
</p>
<p></p>
<div>if (var->getType().getTypePtr()->isArrayType()) //if the variable declaration is an array type, gets its dimensions</div>
<div>{</div>
<p></p>
<p></p>
<div>     const ConstantArrayType *array = astContext->getAsConstantArrayType(var->getType());</div>
<div>     string type;</div>
<div>     int i = 1; //dimensions counter</div>
<div>     do{</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>type = array->getElementType().getAsString();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>i++; </div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>const ConstantArrayType *array = astContext->getAsConstantArrayType(array->getElementType());</div>
<div>     }while();</div>
<div>     cout << type << " ";</div>
<div>     for (int k = 0; k < i; k++)</div>
<div>           cout << "[number] ";</div>
<div>      cout << endl;</div>
}
<p></p>
</div>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<br>
</div>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
What I want to achieve is when I find a declaration in the source code am analysing for example</div>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<br>
</div>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
int [111] [222] [333] </div>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<br>
</div>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
I want to print it like this</div>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<br>
</div>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
int [number] [number] [number]</div>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<br>
</div>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
I am having a hard time finding the number of dimensions of the declared array.</div>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
I dont know automatically keep extracting the dimensions of a multiimensional array as 1-dimensional arrays. The problem is inside the do-while loop.</div>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<br>
</div>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
Please help me .. </div>
</div>
</body>
</html>