================ @@ -413,38 +588,18 @@ ProgramStateRef CStringChecker::CheckLocation(CheckerContext &C, if (!ER) return state; - SValBuilder &svalBuilder = C.getSValBuilder(); - ASTContext &Ctx = svalBuilder.getContext(); - // Get the index of the accessed element. - NonLoc Idx = ER->getIndex(); - - if (CK == CharKind::Regular) { - if (ER->getValueType() != Ctx.CharTy) - return state; - } else { - if (ER->getValueType() != Ctx.WideCharTy) - return state; - - QualType SizeTy = Ctx.getSizeType(); - NonLoc WideSize = - svalBuilder - .makeIntVal(Ctx.getTypeSizeInChars(Ctx.WideCharTy).getQuantity(), - SizeTy) - .castAs<NonLoc>(); - SVal Offset = svalBuilder.evalBinOpNN(state, BO_Mul, Idx, WideSize, SizeTy); - if (Offset.isUnknown()) - return state; - Idx = Offset.castAs<NonLoc>(); - } + std::optional<NonLoc> Idx = getIndex(state, ER, CK); + if (!Idx) + return state; // Get the size of the array. const auto *superReg = cast<SubRegion>(ER->getSuperRegion()); DefinedOrUnknownSVal Size = getDynamicExtent(state, superReg, C.getSValBuilder()); ProgramStateRef StInBound, StOutBound; - std::tie(StInBound, StOutBound) = state->assumeInBoundDual(Idx, Size); + std::tie(StInBound, StOutBound) = state->assumeInBoundDual(*Idx, Size); ---------------- NagyDonat wrote:
Perhaps apply a [structured binding](https://en.cppreference.com/w/cpp/language/structured_binding) instead of `std::tie`? https://github.com/llvm/llvm-project/pull/95408 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits