================ @@ -1704,16 +1704,23 @@ static RegionOffset calculateOffset(const MemRegion *R) { if (SymbolicOffsetBase) continue; - // Get the field number. - unsigned idx = 0; - for (RecordDecl::field_iterator FI = RD->field_begin(), - FE = RD->field_end(); FI != FE; ++FI, ++idx) { - if (FR->getDecl() == *FI) - break; + auto MaybeFieldIdx = [FR, RD]() -> std::optional<unsigned> { + assert(FR->getDecl()->getCanonicalDecl() == FR->getDecl()); ---------------- NagyDonat wrote:
Please move this assertion out of the immediately executed lambda expression -- let's keep it as simple as possible. Also consider adding something like `&& "This function should always be called with a canonical declaration."` because IMO this would be helpful for a reader (who otherwise may have thought about a more fundamental reason for asserting this). https://github.com/llvm/llvm-project/pull/156668 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits