@@ -151,8 +151,9 @@ PointerVariableConstraint::PointerVariableConstraint(const QualType &QT,
151151 ArrPresent = false ;
152152
153153 bool IsDeclTy = false ;
154+
155+ auto &ABInfo = I.getABoundsInfo ();
154156 if (D != nullptr ) {
155- auto &ABInfo = I.getABoundsInfo ();
156157 if (ABInfo.tryGetVariable (D, BKey)) {
157158 ValidBoundsKey = true ;
158159 }
@@ -210,6 +211,7 @@ PointerVariableConstraint::PointerVariableConstraint(const QualType &QT,
210211 bool VarCreated = false ;
211212 bool IsArr = false ;
212213 bool IsIncompleteArr = false ;
214+ bool IsTopMost = true ;
213215 OriginallyChecked = false ;
214216 uint32_t TypeIdx = 0 ;
215217 std::string Npre = inFunc ? ((*inFunc)+" :" ) : " " ;
@@ -268,7 +270,14 @@ PointerVariableConstraint::PointerVariableConstraint(const QualType &QT,
268270 // See if there is a constant size to this array type at this position.
269271 if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(Ty)) {
270272 arrSizes[TypeIdx] = std::pair<OriginalArrType,uint64_t >(
271- O_SizedArray,CAT->getSize ().getZExtValue ());
273+ O_SizedArray, CAT->getSize ().getZExtValue ());
274+
275+ // If this is the top-most pointer variable?
276+ if (hasBoundsKey () && IsTopMost) {
277+ BoundsKey CBKey = ABInfo.getConstKey (CAT->getSize ().getZExtValue ());
278+ ABounds *NB = new CountBound (CBKey);
279+ ABInfo.insertDeclaredBounds (D, NB);
280+ }
272281 } else {
273282 arrSizes[TypeIdx] = std::pair<OriginalArrType,uint64_t >(
274283 O_UnSizedArray,0 );
@@ -316,6 +325,7 @@ PointerVariableConstraint::PointerVariableConstraint(const QualType &QT,
316325 TypeIdx++;
317326 Npre = Npre + " *" ;
318327 VK = VarAtom::V_Other; // only the outermost pointer considered a param/return
328+ IsTopMost = false ;
319329 }
320330 insertQualType (TypeIdx, QTy);
321331
@@ -1148,6 +1158,16 @@ bool PointerVariableConstraint::isTopCvarUnsizedArr() const {
11481158 return true ;
11491159}
11501160
1161+ bool PointerVariableConstraint::hasSomeSizedArr () const {
1162+ for (auto &AS : arrSizes) {
1163+ if (AS.second .first == O_SizedArray ||
1164+ AS.second .second == O_UnSizedArray) {
1165+ return true ;
1166+ }
1167+ }
1168+ return false ;
1169+ }
1170+
11511171bool PointerVariableConstraint::
11521172 solutionEqualTo (Constraints &CS, const ConstraintVariable *CV) const {
11531173 bool Ret = false ;
0 commit comments