[PATCH] D61136: [Analyzer] Refactor begin and end symbol creation
This revision was automatically updated to reflect the committed changes. Closed by commit rL361141: [Analyzer] Refactor begin and end symbol creation (authored by baloghadamsoftware, committed by ). Herald added a project: LLVM. Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D61136?vs=197980=200243#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61136/new/ https://reviews.llvm.org/D61136 Files: cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp Index: cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp === --- cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp @@ -300,10 +300,13 @@ SymbolRef getContainerBegin(ProgramStateRef State, const MemRegion *Cont); SymbolRef getContainerEnd(ProgramStateRef State, const MemRegion *Cont); ProgramStateRef createContainerBegin(ProgramStateRef State, - const MemRegion *Cont, - const SymbolRef Sym); + const MemRegion *Cont, const Expr *E, + QualType T, const LocationContext *LCtx, + unsigned BlockCount); ProgramStateRef createContainerEnd(ProgramStateRef State, const MemRegion *Cont, - const SymbolRef Sym); + const Expr *E, QualType T, + const LocationContext *LCtx, + unsigned BlockCount); const IteratorPosition *getIteratorPosition(ProgramStateRef State, const SVal ); ProgramStateRef setIteratorPosition(ProgramStateRef State, const SVal , @@ -1142,11 +1145,9 @@ auto State = C.getState(); auto BeginSym = getContainerBegin(State, ContReg); if (!BeginSym) { -auto = C.getSymbolManager(); -BeginSym = SymMgr.conjureSymbol(CE, C.getLocationContext(), -C.getASTContext().LongTy, C.blockCount()); -State = assumeNoOverflow(State, BeginSym, 4); -State = createContainerBegin(State, ContReg, BeginSym); +State = createContainerBegin(State, ContReg, CE, C.getASTContext().LongTy, + C.getLocationContext(), C.blockCount()); +BeginSym = getContainerBegin(State, ContReg); } State = setIteratorPosition(State, RetVal, IteratorPosition::getPosition(ContReg, BeginSym)); @@ -1166,11 +1167,9 @@ auto State = C.getState(); auto EndSym = getContainerEnd(State, ContReg); if (!EndSym) { -auto = C.getSymbolManager(); -EndSym = SymMgr.conjureSymbol(CE, C.getLocationContext(), - C.getASTContext().LongTy, C.blockCount()); -State = assumeNoOverflow(State, EndSym, 4); -State = createContainerEnd(State, ContReg, EndSym); +State = createContainerEnd(State, ContReg, CE, C.getASTContext().LongTy, + C.getLocationContext(), C.blockCount()); +EndSym = getContainerEnd(State, ContReg); } State = setIteratorPosition(State, RetVal, IteratorPosition::getPosition(ContReg, EndSym)); @@ -1934,32 +1933,47 @@ } ProgramStateRef createContainerBegin(ProgramStateRef State, - const MemRegion *Cont, - const SymbolRef Sym) { + const MemRegion *Cont, const Expr *E, + QualType T, const LocationContext *LCtx, + unsigned BlockCount) { // Only create if it does not exist const auto *CDataPtr = getContainerData(State, Cont); + if (CDataPtr && CDataPtr->getBegin()) +return State; + + auto = State->getSymbolManager(); + const SymbolConjured *Sym = SymMgr.conjureSymbol(E, LCtx, T, BlockCount, + "begin"); + State = assumeNoOverflow(State, Sym, 4); + if (CDataPtr) { -if (CDataPtr->getBegin()) { - return State; -} const auto CData = CDataPtr->newBegin(Sym); return setContainerData(State, Cont, CData); } + const auto CData = ContainerData::fromBegin(Sym); return setContainerData(State, Cont, CData); } ProgramStateRef createContainerEnd(ProgramStateRef State, const MemRegion *Cont, - const SymbolRef Sym) { + const Expr *E, QualType T, + const LocationContext *LCtx, + unsigned BlockCount) { // Only create if it does not exist const auto *CDataPtr = getContainerData(State, Cont); + if (CDataPtr && CDataPtr->getEnd()) +return State; + + auto =
[PATCH] D61136: [Analyzer] Refactor begin and end symbol creation
NoQ accepted this revision. NoQ added a comment. Thx! CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61136/new/ https://reviews.llvm.org/D61136 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D61136: [Analyzer] Refactor begin and end symbol creation
baloghadamsoftware updated this revision to Diff 197980. baloghadamsoftware retitled this revision from "[Analyzer] IteratorChecker - Ensure end()>=begin() and refactor begin and end symbol creation" to "[Analyzer] Refactor begin and end symbol creation". baloghadamsoftware edited the summary of this revision. baloghadamsoftware added a comment. `SymbolConjured *` written, feature removed, just refactoring. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61136/new/ https://reviews.llvm.org/D61136 Files: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp Index: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp === --- lib/StaticAnalyzer/Checkers/IteratorChecker.cpp +++ lib/StaticAnalyzer/Checkers/IteratorChecker.cpp @@ -300,10 +300,13 @@ SymbolRef getContainerBegin(ProgramStateRef State, const MemRegion *Cont); SymbolRef getContainerEnd(ProgramStateRef State, const MemRegion *Cont); ProgramStateRef createContainerBegin(ProgramStateRef State, - const MemRegion *Cont, - const SymbolRef Sym); + const MemRegion *Cont, const Expr *E, + QualType T, const LocationContext *LCtx, + unsigned BlockCount); ProgramStateRef createContainerEnd(ProgramStateRef State, const MemRegion *Cont, - const SymbolRef Sym); + const Expr *E, QualType T, + const LocationContext *LCtx, + unsigned BlockCount); const IteratorPosition *getIteratorPosition(ProgramStateRef State, const SVal ); ProgramStateRef setIteratorPosition(ProgramStateRef State, const SVal , @@ -1142,11 +1145,9 @@ auto State = C.getState(); auto BeginSym = getContainerBegin(State, ContReg); if (!BeginSym) { -auto = C.getSymbolManager(); -BeginSym = SymMgr.conjureSymbol(CE, C.getLocationContext(), -C.getASTContext().LongTy, C.blockCount()); -State = assumeNoOverflow(State, BeginSym, 4); -State = createContainerBegin(State, ContReg, BeginSym); +State = createContainerBegin(State, ContReg, CE, C.getASTContext().LongTy, + C.getLocationContext(), C.blockCount()); +BeginSym = getContainerBegin(State, ContReg); } State = setIteratorPosition(State, RetVal, IteratorPosition::getPosition(ContReg, BeginSym)); @@ -1166,11 +1167,9 @@ auto State = C.getState(); auto EndSym = getContainerEnd(State, ContReg); if (!EndSym) { -auto = C.getSymbolManager(); -EndSym = SymMgr.conjureSymbol(CE, C.getLocationContext(), - C.getASTContext().LongTy, C.blockCount()); -State = assumeNoOverflow(State, EndSym, 4); -State = createContainerEnd(State, ContReg, EndSym); +State = createContainerEnd(State, ContReg, CE, C.getASTContext().LongTy, + C.getLocationContext(), C.blockCount()); +EndSym = getContainerEnd(State, ContReg); } State = setIteratorPosition(State, RetVal, IteratorPosition::getPosition(ContReg, EndSym)); @@ -1934,32 +1933,47 @@ } ProgramStateRef createContainerBegin(ProgramStateRef State, - const MemRegion *Cont, - const SymbolRef Sym) { + const MemRegion *Cont, const Expr *E, + QualType T, const LocationContext *LCtx, + unsigned BlockCount) { // Only create if it does not exist const auto *CDataPtr = getContainerData(State, Cont); + if (CDataPtr && CDataPtr->getBegin()) +return State; + + auto = State->getSymbolManager(); + const SymbolConjured *Sym = SymMgr.conjureSymbol(E, LCtx, T, BlockCount, + "begin"); + State = assumeNoOverflow(State, Sym, 4); + if (CDataPtr) { -if (CDataPtr->getBegin()) { - return State; -} const auto CData = CDataPtr->newBegin(Sym); return setContainerData(State, Cont, CData); } + const auto CData = ContainerData::fromBegin(Sym); return setContainerData(State, Cont, CData); } ProgramStateRef createContainerEnd(ProgramStateRef State, const MemRegion *Cont, - const SymbolRef Sym) { + const Expr *E, QualType T, + const LocationContext *LCtx, + unsigned BlockCount) { // Only create if it does not exist const auto *CDataPtr = getContainerData(State, Cont); + if (CDataPtr && CDataPtr->getEnd()) +return State; + + auto =