File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change 4242#include < bcl/utility.h>
4343#include < llvm/Pass.h>
4444#include < stack>
45- #include < iostream>
4645
4746using namespace clang ;
4847using namespace llvm ;
@@ -53,20 +52,23 @@ using namespace tsar;
5352
5453static int getDimensionsNum (QualType qt, std::vector<int >& default_dimensions) {
5554 int res = 0 ;
56- if (qt -> isPointerType ()) { // todo: multidimensional dynamyc-sized arrays
57- return 1 ;
58- }
55+ bool sizeIsKnown = true ;
5956 while (1 ) {
6057 if (qt -> isArrayType ()) {
6158 auto at = qt->getAsArrayTypeUnsafe ();
62- if (auto t = dyn_cast_or_null<ConstantArrayType>(at)) { // get size
63- uint64_t dim = t -> getSize ().getLimitedValue ();
64- default_dimensions.push_back (dim);
59+ auto t = dyn_cast_or_null<ConstantArrayType>(at);
60+ if (sizeIsKnown && t) { // get size
61+ uint64_t dim = t -> getSize ().getLimitedValue ();
62+ default_dimensions.push_back (dim);
6563 }
6664 qt = at -> getElementType ();
6765 res++;
66+ } else if (qt -> isPointerType ()) {
67+ sizeIsKnown = false ;
68+ qt = qt -> getPointeeType ();
69+ res++;
6870 } else {
69- return res;
71+ return res;
7072 }
7173 }
7274}
You can’t perform that action at this time.
0 commit comments