Skip to content

Commit ae90977

Browse files
committed
add pointers initialization
1 parent acc7714 commit ae90977

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

lib/Transform/Clang/RemoveFirstPrivate.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
#include <bcl/utility.h>
4343
#include <llvm/Pass.h>
4444
#include <stack>
45-
#include <iostream>
4645

4746
using namespace clang;
4847
using namespace llvm;
@@ -53,20 +52,23 @@ using namespace tsar;
5352

5453
static 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
}

0 commit comments

Comments
 (0)