Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -1527,7 +1527,15 @@ if (hasVisibleUpdate(Pred, Pred->getState()->getSVal(R), Succ, V)) { Optional PS = Succ->getLocationAs(); - if (!PS || PS->getLocationValue() != R) + if (!PS) + return nullptr; + + const auto *LPtr = PS->getLocationValue(); + if (!LPtr) + return nullptr; + const auto *L = reinterpret_cast(LPtr); + + if (PS->getLocationValue() != R && !R->isSubRegionOf(L)) return nullptr; } @@ -1539,7 +1547,12 @@ if (const BinaryOperator *BO = P->getStmtAs()) { if (BO->isAssignmentOp()) InitE = BO->getRHS(); + } else if (const CXXOperatorCallExpr *CE = + P->getStmtAs()) { + if (CE->isAssignmentOp()) + InitE = CE->getArg(1); } + // If we have a declaration like 'S s{1,2}' that needs special // handling, we handle it here. else if (const auto *DS = P->getStmtAs()) { @@ -2157,7 +2170,7 @@ return peelOffOuterExpr(SubEx, N); if (auto *UO = dyn_cast(Ex)) { - if (UO->getOpcode() == UO_LNot) + if (UO->getOpcode() == UO_LNot || UO->getOpcode() == clang::UO_Minus) return peelOffOuterExpr(UO->getSubExpr(), N); // FIXME: There's a hack in our Store implementation that always computes