Index: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp +++ clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp @@ -87,7 +87,8 @@ check::Bind, check::LiveSymbols, check::DeadSymbols> { using AdvanceFn = void (IteratorModeling::*)(CheckerContext &, const Expr *, - SVal, SVal, SVal) const; + SVal, SVal, SVal, const Expr *, + const Expr *) const; void handleOverloadedOperator(CheckerContext &C, const CallEvent &Call, OverloadedOperatorKind Op) const; @@ -96,26 +97,29 @@ const AdvanceFn *Handler) const; void handleComparison(CheckerContext &C, const Expr *CE, SVal RetVal, - const SVal &LVal, const SVal &RVal, - OverloadedOperatorKind Op) const; + SVal LVal, SVal RVal, OverloadedOperatorKind Op) const; void processComparison(CheckerContext &C, ProgramStateRef State, - SymbolRef Sym1, SymbolRef Sym2, const SVal &RetVal, + SymbolRef Sym1, SymbolRef Sym2, SVal RetVal, OverloadedOperatorKind Op) const; - void handleIncrement(CheckerContext &C, const SVal &RetVal, const SVal &Iter, - bool Postfix) const; - void handleDecrement(CheckerContext &C, const SVal &RetVal, const SVal &Iter, - bool Postfix) const; + void handleIncrement(CheckerContext &C, SVal RetVal, SVal Iter, + const Expr *ItEx, bool Postfix) const; + void handleDecrement(CheckerContext &C, SVal RetVal, SVal Iter, + const Expr *ItEx, bool Postfix) const; void handleRandomIncrOrDecr(CheckerContext &C, const Expr *CE, - OverloadedOperatorKind Op, const SVal &RetVal, - const SVal &LHS, const SVal &RHS) const; + OverloadedOperatorKind Op, SVal RetVal, SVal LHS, + SVal RHS, const Expr *LHSEx, + const Expr *RHSEx = nullptr) const; void handleAdvance(CheckerContext &C, const Expr *CE, SVal RetVal, SVal Iter, - SVal Amount) const; + SVal Amount, const Expr *ItEx, const Expr *AmEx) const; void handlePrev(CheckerContext &C, const Expr *CE, SVal RetVal, SVal Iter, - SVal Amount) const; + SVal Amount, const Expr *ItEx, const Expr *AmEx) const; void handleNext(CheckerContext &C, const Expr *CE, SVal RetVal, SVal Iter, - SVal Amount) const; - void assignToContainer(CheckerContext &C, const Expr *CE, const SVal &RetVal, + SVal Amount, const Expr *ItEx, const Expr *AmEx) const; + void assignToContainer(CheckerContext &C, const Expr *CE, SVal RetVal, const MemRegion *Cont) const; + const NoteTag *getChangeTag(CheckerContext &C, StringRef Text, + const Expr *ItEx, int64_t Amount = 0, + const Expr *AmEx = nullptr) const; bool noChangeInAdvance(CheckerContext &C, SVal Iter, const Expr *CE) const; void printState(raw_ostream &Out, ProgramStateRef State, const char *NL, const char *Sep) const override; @@ -144,8 +148,6 @@ void checkPostCall(const CallEvent &Call, CheckerContext &C) const; void checkBind(SVal Loc, SVal Val, const Stmt *S, CheckerContext &C) const; - void checkPostStmt(const CXXConstructExpr *CCE, CheckerContext &C) const; - void checkPostStmt(const DeclStmt *DS, CheckerContext &C) const; void checkPostStmt(const MaterializeTemporaryExpr *MTE, CheckerContext &C) const; void checkLiveSymbols(ProgramStateRef State, SymbolReaper &SR) const; @@ -153,7 +155,7 @@ }; bool isSimpleComparisonOperator(OverloadedOperatorKind OK); -ProgramStateRef removeIteratorPosition(ProgramStateRef State, const SVal &Val); +ProgramStateRef removeIteratorPosition(ProgramStateRef State, SVal Val); ProgramStateRef relateSymbols(ProgramStateRef State, SymbolRef Sym1, SymbolRef Sym2, bool Equal); bool isBoundThroughLazyCompoundVal(const Environment &Env, @@ -242,10 +244,12 @@ CheckerContext &C) const { /* Transfer iterator state to temporary objects */ auto State = C.getState(); - const auto *Pos = getIteratorPosition(State, C.getSVal(MTE->getSubExpr())); + SVal OldVal = C.getSVal(MTE->getSubExpr()); + SVal NewVal = C.getSVal(MTE); + const auto *Pos = getIteratorPosition(State, OldVal); if (!Pos) return; - State = setIteratorPosition(State, C.getSVal(MTE), *Pos); + State = setIteratorPosition(State, NewVal, *Pos); C.addTransition(State); } @@ -324,36 +328,39 @@ if (Call.getNumArgs() >= 1 && Call.getArgExpr(0)->getType()->isIntegralOrEnumerationType()) { handleRandomIncrOrDecr(C, OrigExpr, Op, Call.getReturnValue(), - InstCall->getCXXThisVal(), Call.getArgSVal(0)); + InstCall->getCXXThisVal(), Call.getArgSVal(0), + InstCall->getCXXThisExpr(), + Call.getArgExpr(0)); return; } } else { if (Call.getNumArgs() >= 2 && Call.getArgExpr(1)->getType()->isIntegralOrEnumerationType()) { handleRandomIncrOrDecr(C, OrigExpr, Op, Call.getReturnValue(), - Call.getArgSVal(0), Call.getArgSVal(1)); + Call.getArgSVal(0), Call.getArgSVal(1), + Call.getArgExpr(0), Call.getArgExpr(1)); return; } } } else if (isIncrementOperator(Op)) { if (const auto *InstCall = dyn_cast(&Call)) { handleIncrement(C, Call.getReturnValue(), InstCall->getCXXThisVal(), - Call.getNumArgs()); + InstCall->getCXXThisExpr(), Call.getNumArgs()); return; } handleIncrement(C, Call.getReturnValue(), Call.getArgSVal(0), - Call.getNumArgs()); + Call.getArgExpr(0), Call.getNumArgs()); return; } else if (isDecrementOperator(Op)) { if (const auto *InstCall = dyn_cast(&Call)) { handleDecrement(C, Call.getReturnValue(), InstCall->getCXXThisVal(), - Call.getNumArgs()); + InstCall->getCXXThisExpr(), Call.getNumArgs()); return; } handleDecrement(C, Call.getReturnValue(), Call.getArgSVal(0), - Call.getNumArgs()); + Call.getArgExpr(0), Call.getNumArgs()); return; } } @@ -365,7 +372,8 @@ const AdvanceFn *Handler) const { if (!C.wasInlined) { (this->**Handler)(C, OrigExpr, Call.getReturnValue(), - Call.getArgSVal(0), Call.getArgSVal(1)); + Call.getArgSVal(0), Call.getArgSVal(1), + Call.getArgExpr(0), Call.getArgExpr(1)); return; } @@ -376,15 +384,16 @@ if (IdInfo->getName() == "advance") { if (noChangeInAdvance(C, Call.getArgSVal(0), OrigExpr)) { (this->**Handler)(C, OrigExpr, Call.getReturnValue(), - Call.getArgSVal(0), Call.getArgSVal(1)); + Call.getArgSVal(0), Call.getArgSVal(1), + Call.getArgExpr(0), Call.getArgExpr(1)); } } } } void IteratorModeling::handleComparison(CheckerContext &C, const Expr *CE, - SVal RetVal, const SVal &LVal, - const SVal &RVal, + SVal RetVal, SVal LVal, + SVal RVal, OverloadedOperatorKind Op) const { // Record the operands and the operator of the comparison for the next // evalAssume, if the result is a symbolic expression. If it is a concrete @@ -437,7 +446,7 @@ void IteratorModeling::processComparison(CheckerContext &C, ProgramStateRef State, SymbolRef Sym1, - SymbolRef Sym2, const SVal &RetVal, + SymbolRef Sym2, SVal RetVal, OverloadedOperatorKind Op) const { if (const auto TruthVal = RetVal.getAs()) { if ((State = relateSymbols(State, Sym1, Sym2, @@ -465,8 +474,9 @@ } } -void IteratorModeling::handleIncrement(CheckerContext &C, const SVal &RetVal, - const SVal &Iter, bool Postfix) const { +void IteratorModeling::handleIncrement(CheckerContext &C, SVal RetVal, + SVal Iter, const Expr *ItEx, + bool Postfix) const { // Increment the symbolic expressions which represents the position of the // iterator auto State = C.getState(); @@ -486,13 +496,15 @@ assert(NewPos && "Iterator should have position after successful advancement"); + const NoteTag *ChangeTag = getChangeTag(C, "incremented", ItEx, 1); State = setIteratorPosition(State, Iter, *NewPos); State = setIteratorPosition(State, RetVal, Postfix ? *Pos : *NewPos); - C.addTransition(State); + C.addTransition(State, ChangeTag); } -void IteratorModeling::handleDecrement(CheckerContext &C, const SVal &RetVal, - const SVal &Iter, bool Postfix) const { +void IteratorModeling::handleDecrement(CheckerContext &C, SVal RetVal, + SVal Iter, const Expr *ItEx, + bool Postfix) const { // Decrement the symbolic expressions which represents the position of the // iterator auto State = C.getState(); @@ -512,17 +524,18 @@ assert(NewPos && "Iterator should have position after successful advancement"); + const NoteTag *ChangeTag = getChangeTag(C, "decremented", ItEx, 1); State = setIteratorPosition(State, Iter, *NewPos); State = setIteratorPosition(State, RetVal, Postfix ? *Pos : *NewPos); - C.addTransition(State); + C.addTransition(State, ChangeTag); } -void IteratorModeling::handleRandomIncrOrDecr(CheckerContext &C, - const Expr *CE, +void IteratorModeling::handleRandomIncrOrDecr(CheckerContext &C, const Expr *CE, OverloadedOperatorKind Op, - const SVal &RetVal, - const SVal &LHS, - const SVal &RHS) const { + SVal RetVal, + SVal LHS, SVal RHS, + const Expr *LHSEx, + const Expr *RHSEx) const { // Increment or decrement the symbolic expressions which represents the // position of the iterator auto State = C.getState(); @@ -546,8 +559,19 @@ assert(NewPos && "Iterator should have position after successful advancement"); + auto &SVB = State->getStateManager().getSValBuilder(); + int64_t ChangeVal = + SVB.getKnownValue(State, *value)->getExtValue(); + StringRef ChangeText = + ((Op == OO_Plus || Op == OO_PlusEqual) != (ChangeVal <= 0)) ? + "incremented" : "decremented"; + if (!ChangeVal) + ChangeText = "unchanged"; + + const NoteTag *ChangeTag = getChangeTag(C, ChangeText, LHSEx, + std::abs(ChangeVal), RHSEx); State = setIteratorPosition(NewState, TgtVal, *NewPos); - C.addTransition(State); + C.addTransition(State, ChangeTag); } else { assignToContainer(C, CE, TgtVal, Pos->getContainer()); } @@ -555,22 +579,25 @@ void IteratorModeling::handleAdvance(CheckerContext &C, const Expr *CE, SVal RetVal, SVal Iter, - SVal Amount) const { - handleRandomIncrOrDecr(C, CE, OO_PlusEqual, RetVal, Iter, Amount); + SVal Amount, const Expr *ItEx, + const Expr *AmEx) const { + handleRandomIncrOrDecr(C, CE, OO_PlusEqual, RetVal, Iter, Amount, ItEx, AmEx); } void IteratorModeling::handlePrev(CheckerContext &C, const Expr *CE, - SVal RetVal, SVal Iter, SVal Amount) const { - handleRandomIncrOrDecr(C, CE, OO_Minus, RetVal, Iter, Amount); + SVal RetVal, SVal Iter, SVal Amount, + const Expr *ItEx, const Expr *AmEx) const { + handleRandomIncrOrDecr(C, CE, OO_Minus, RetVal, Iter, Amount, ItEx, AmEx); } void IteratorModeling::handleNext(CheckerContext &C, const Expr *CE, - SVal RetVal, SVal Iter, SVal Amount) const { - handleRandomIncrOrDecr(C, CE, OO_Plus, RetVal, Iter, Amount); + SVal RetVal, SVal Iter, SVal Amount, + const Expr *ItEx, const Expr *AmEx) const { + handleRandomIncrOrDecr(C, CE, OO_Plus, RetVal, Iter, Amount, ItEx, AmEx); } void IteratorModeling::assignToContainer(CheckerContext &C, const Expr *CE, - const SVal &RetVal, + SVal RetVal, const MemRegion *Cont) const { Cont = Cont->getMostDerivedObjectRegion(); @@ -606,6 +633,34 @@ return PosBefore->getOffset() == PosAfter->getOffset(); } +const NoteTag *IteratorModeling::getChangeTag(CheckerContext &C, StringRef Text, + const Expr *ItEx, int64_t Amount, + const Expr *AmEx) const { + if (const auto *CCE = dyn_cast(ItEx)) { + ItEx = CCE->getArg(0); + } + + StringRef Name; + if (const auto *DRE = dyn_cast(ItEx->IgnoreParenCasts())) { + Name = DRE->getDecl()->getName(); + } + + return C.getNoteTag( + [Text, Name, Amount, AmEx](PathSensitiveBugReport &BR) -> std::string { + SmallString<256> Msg; + llvm::raw_svector_ostream Out(Msg); + Out << "Iterator " << (!Name.empty() ? ("'" + Name.str() + "' ") : "") + << Text; + if (Amount) { + Out << " by " << Amount; + } + if (AmEx) { + bugreporter::trackExpressionValue(BR.getErrorNode(), AmEx, BR); + } + return std::string(Out.str()); + }); +} + void IteratorModeling::printState(raw_ostream &Out, ProgramStateRef State, const char *NL, const char *Sep) const { auto SymbolMap = State->get(); @@ -641,7 +696,7 @@ return OK == OO_EqualEqual || OK == OO_ExclaimEqual; } -ProgramStateRef removeIteratorPosition(ProgramStateRef State, const SVal &Val) { +ProgramStateRef removeIteratorPosition(ProgramStateRef State, SVal Val) { if (auto Reg = Val.getAsRegion()) { Reg = Reg->getMostDerivedObjectRegion(); return State->remove(Reg); Index: clang/test/Analysis/iterator-modelling.cpp =================================================================== --- clang/test/Analysis/iterator-modelling.cpp +++ clang/test/Analysis/iterator-modelling.cpp @@ -1,14 +1,37 @@ -// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false %s -verify - -// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify - -// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 -DSTD_ADVANCE_INLINE_LEVEL=0 %s -verify - -// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 -DSTD_ADVANCE_INLINE_LEVEL=1 %s -verify - -// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 -DSTD_ADVANCE_INLINE_LEVEL=2 %s -verify - -// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true %s 2>&1 | FileCheck %s +// RUN: %clang_analyze_cc1 -std=c++11\ +// RUN: -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection\ +// RUN: -analyzer-config aggressive-binary-operation-simplification=true\ +// RUN: -analyzer-config c++-container-inlining=false -analyzer-output=text %s\ +// RUN: -verify + +// RUN: %clang_analyze_cc1 -std=c++11\ +// RUN: -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection\ +// RUN: -analyzer-config aggressive-binary-operation-simplification=true\ +// RUN: -analyzer-config c++-container-inlining=true -DINLINE=1\ +// RUN: -analyzer-output=text %s -verify + +// RUN: %clang_analyze_cc1 -std=c++11\ +// RUN: -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection\ +// RUN: -analyzer-config aggressive-binary-operation-simplification=true\ +// RUN: -analyzer-config c++-container-inlining=true -DINLINE=1\ +// RUN: -DSTD_ADVANCE_INLINE_LEVEL=0 -analyzer-output=text %s -verify + +// RUN: %clang_analyze_cc1 -std=c++11\ +// RUN: -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection\ +// RUN: -analyzer-config aggressive-binary-operation-simplification=true\ +// RUN: -analyzer-config c++-container-inlining=true -DINLINE=1\ +// RUN: -DSTD_ADVANCE_INLINE_LEVEL=1 -analyzer-output=text %s -verify + +// RUN: %clang_analyze_cc1 -std=c++11\ +// RUN: -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection\ +// RUN: -analyzer-config aggressive-binary-operation-simplification=true\ +// RUN: -analyzer-config c++-container-inlining=true -DINLINE=1\ +// RUN: -DSTD_ADVANCE_INLINE_LEVEL=2 -analyzer-output=text %s -verify + +// RUN: %clang_analyze_cc1 -std=c++11\ +// RUN: -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorModeling,debug.ExprInspection\ +// RUN: -analyzer-config aggressive-binary-operation-simplification=true %s\ +// RUN: 2>&1 | FileCheck %s #include "Inputs/system-header-simulator-cxx.h" @@ -32,8 +55,10 @@ auto i = v.begin(); clang_analyzer_eval(clang_analyzer_iterator_container(i) == &v); // expected-warning{{TRUE}} + // expected-note@-1{{TRUE}} clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()"); clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.begin()}} + //expected-note@-1{{$v.begin()}} if (i != v.begin()) { clang_analyzer_warnIfReached(); @@ -44,8 +69,10 @@ auto i = v.end(); clang_analyzer_eval(clang_analyzer_iterator_container(i) == &v); // expected-warning{{TRUE}} + // expected-note@-1{{TRUE}} clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()"); clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.end()}} + //expected-note@-1{{$v.end()}} if (i != v.end()) { clang_analyzer_warnIfReached(); @@ -57,10 +84,12 @@ clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()"); - auto j = ++i; + auto j = ++i; // expected-note 2{{Iterator 'i' incremented by 1}} clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.begin() + 1}} + //expected-note@-1{{$v.begin() + 1}} clang_analyzer_express(clang_analyzer_iterator_position(j)); //expected-warning{{$v.begin() + 1}} + //expected-note@-1{{$v.begin() + 1}} } void prefix_decrement(const std::vector &v) { @@ -68,10 +97,12 @@ clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()"); - auto j = --i; + auto j = --i; // expected-note 2{{Iterator 'i' decremented by 1}} clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.end() - 1}} + //expected-note@-1{{$v.end() - 1}} clang_analyzer_express(clang_analyzer_iterator_position(j)); //expected-warning{{$v.end() - 1}} + //expected-note@-1{{$v.end() - 1}} } void postfix_increment(const std::vector &v) { @@ -79,10 +110,12 @@ clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()"); - auto j = i++; + auto j = i++; // expected-note 2{{Iterator 'i' incremented by 1}} clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.begin() + 1}} + //expected-note@-1{{$v.begin() + 1}} clang_analyzer_express(clang_analyzer_iterator_position(j)); //expected-warning{{$v.begin()}} + //expected-note@-1{{$v.begin()}} } void postfix_decrement(const std::vector &v) { @@ -90,10 +123,12 @@ clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()"); - auto j = i--; + auto j = i--; // expected-note 2{{Iterator 'i' decremented by 1}} clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.end() - 1}} + //expected-note@-1{{$v.end() - 1}} clang_analyzer_express(clang_analyzer_iterator_position(j)); //expected-warning{{$v.end()}} + //expected-note@-1{{$v.end()}} } void plus_equal(const std::vector &v) { @@ -101,9 +136,10 @@ clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()"); - i += 2; + i += 2; // expected-note{{Iterator 'i' incremented by 2}} clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.begin() + 2}} + //expected-note@-1{{$v.begin() + 2}} } void plus_equal_negative(const std::vector &v) { @@ -111,9 +147,21 @@ clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()"); - i += -2; + i += -2; // expected-note{{Iterator 'i' decremented by 2}} clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.end() - 2}} + //expected-note@-1{{$v.end() - 2}} +} + +void plus_equal_zero(const std::vector &v) { + auto i = v.end(); + + clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()"); + + i += 0; // expected-note{{Iterator 'i' unchanged}} + + clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.end()}} + //expected-note@-1{{$v.end()}} } void minus_equal(const std::vector &v) { @@ -121,9 +169,10 @@ clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()"); - i -= 2; + i -= 2; // expected-note{{Iterator 'i' decremented by 2}} clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.end() - 2}} + //expected-note@-1{{$v.end() - 2}} } void minus_equal_negative(const std::vector &v) { @@ -131,9 +180,21 @@ clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()"); - i -= -2; + i -= -2; // expected-note{{Iterator 'i' incremented by 2}} clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.begin() + 2}} + //expected-note@-1{{$v.begin() + 2}} +} + +void minus_equal_zero(const std::vector &v) { + auto i = v.begin(); + + clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()"); + + i -= 0; // expected-note{{Iterator 'i' unchanged}} + + clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.begin()}} + //expected-note@-1{{$v.begin()}} } void copy(const std::vector &v) { @@ -144,7 +205,9 @@ auto i2 = i1; clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &v); // expected-warning{{TRUE}} + // expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i2)); //expected-warning{{$v.end()}} + //expected-note@-1{{$v.end()}} } void plus(const std::vector &v) { @@ -152,10 +215,12 @@ clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()"); - auto i2 = i1 + 2; + auto i2 = i1 + 2; // expected-note 2{{Iterator 'i1' incremented by 2}} clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &v); // expected-warning{{TRUE}} + // expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i2)); //expected-warning{{$v.begin() + 2}} + //expected-note@-1{{$v.begin() + 2}} } void plus_negative(const std::vector &v) { @@ -163,10 +228,25 @@ clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()"); - auto i2 = i1 + (-2); + auto i2 = i1 + (-2); // expected-note 2{{Iterator 'i1' decremented by 2}} clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &v); // expected-warning{{TRUE}} + // expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i2)); //expected-warning{{$v.end() - 2}} + //expected-note@-1{{$v.end() - 2}} +} + +void plus_zero(const std::vector &v) { + auto i1 = v.begin(); + + clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()"); + + auto i2 = i1 + 0; // expected-note 2{{Iterator 'i1' unchanged}} + + clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &v); // expected-warning{{TRUE}} + // expected-note@-1{{TRUE}} + clang_analyzer_express(clang_analyzer_iterator_position(i2)); //expected-warning{{$v.begin()}} + //expected-note@-1{{$v.begin()}} } void minus(const std::vector &v) { @@ -174,10 +254,12 @@ clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()"); - auto i2 = i1 - 2; + auto i2 = i1 - 2; // expected-note 2{{Iterator 'i1' decremented by 2}} clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &v); // expected-warning{{TRUE}} + // expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i2)); //expected-warning{{$v.end() - 2}} + //expected-note@-1{{$v.end() - 2}} } void minus_negative(const std::vector &v) { @@ -185,10 +267,25 @@ clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()"); - auto i2 = i1 - (-2); + auto i2 = i1 - (-2); // expected-note 2{{Iterator 'i1' incremented by 2}} clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &v); // expected-warning{{TRUE}} + // expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i2)); //expected-warning{{$v.begin() + 2}} + //expected-note@-1{{$v.begin() + 2}} +} + +void minus_zero(const std::vector &v) { + auto i1 = v.begin(); + + clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()"); + + auto i2 = i1 - 0; // expected-note 2{{Iterator 'i1' unchanged}} + + clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &v); // expected-warning{{TRUE}} + // expected-note@-1{{TRUE}} + clang_analyzer_express(clang_analyzer_iterator_position(i2)); //expected-warning{{$v.begin()}} + //expected-note@-1{{$v.begin()}} } void copy_and_increment1(const std::vector &v) { @@ -197,10 +294,12 @@ clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()"); auto i2 = i1; - ++i1; + ++i1; // expected-note 2{{Iterator 'i1' incremented by 1}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); //expected-warning{{$v.begin() + 1}} + //expected-note@-1{{$v.begin() + 1}} clang_analyzer_express(clang_analyzer_iterator_position(i2)); //expected-warning{{$v.begin()}} + //expected-note@-1{{$v.begin()}} } void copy_and_increment2(const std::vector &v) { @@ -209,10 +308,12 @@ clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()"); auto i2 = i1; - ++i2; + ++i2; // expected-note 2{{Iterator 'i2' incremented by 1}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); //expected-warning{{$v.begin()}} + //expected-note@-1{{$v.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i2)); //expected-warning{{$v.begin() + 1}} + //expected-note@-1{{$v.begin() + 1}} } void copy_and_decrement1(const std::vector &v) { @@ -221,10 +322,12 @@ clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()"); auto i2 = i1; - --i1; + --i1; // expected-note 2{{Iterator 'i1' decremented by 1}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); //expected-warning{{$v.end() - 1}} + //expected-note@-1{{$v.end() - 1}} clang_analyzer_express(clang_analyzer_iterator_position(i2)); //expected-warning{{$v.end()}} + //expected-note@-1{{$v.end()}} } void copy_and_decrement2(const std::vector &v) { @@ -233,10 +336,12 @@ clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()"); auto i2 = i1; - --i2; + --i2; // expected-note 2{{Iterator 'i2' decremented by 1}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); //expected-warning{{$v.end()}} + //expected-note@-1{{$v.end()}} clang_analyzer_express(clang_analyzer_iterator_position(i2)); //expected-warning{{$v.end() - 1}} + //expected-note@-1{{$v.end() - 1}} } /// std::advance(), std::prev(), std::next() @@ -246,9 +351,17 @@ clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()"); - std::advance(i, -1); + std::advance(i, -1); //expected-note 0-1{{Iterator 'i' decremented by 1}} + //expected-note@-1 0-1{{Calling 'advance}} + //expected-note@-2 0-1{{Passing the value -1 via 2nd parameter 'n'}} + //expected-note@Inputs/system-header-simulator-cxx.h:787 0-1{{Calling '__advance}} + //expected-note@Inputs/system-header-simulator-cxx.h:787 0-1{{Passing the value -1 via 2nd parameter 'n'}} + //expected-note@Inputs/system-header-simulator-cxx.h:775 0-1{{Iterator 'it' decremented by 1}} + //expected-note@Inputs/system-header-simulator-cxx.h:787 0-1{{Returning from '__advance}} + //expected-note@-7 0-1{{Returning from 'advance}} clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.end() - 1}} + //expected-note@-1{{$v.end() - 1}} } void std_advance_plus(const std::vector &v) { @@ -256,9 +369,17 @@ clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()"); - std::advance(i, 1); + std::advance(i, 1); //expected-note 0-1{{Iterator 'i' incremented by 1}} + //expected-note@-1 0-1{{Calling 'advance}} + //expected-note@-2 0-1{{Passing the value 1 via 2nd parameter 'n'}} + //expected-note@Inputs/system-header-simulator-cxx.h:787 0-1{{Calling '__advance}} + //expected-note@Inputs/system-header-simulator-cxx.h:787 0-1{{Passing the value 1 via 2nd parameter 'n'}} + //expected-note@Inputs/system-header-simulator-cxx.h:775 0-1{{Iterator 'it' incremented by 1}} + //expected-note@Inputs/system-header-simulator-cxx.h:787 0-1{{Returning from '__advance}} + //expected-note@-7 0-1{{Returning from 'advance}} clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.begin() + 1}} + //expected-note@-1{{$v.begin() + 1}} } void std_prev(const std::vector &v) { @@ -266,9 +387,20 @@ clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()"); - auto j = std::prev(i); + auto j = std::prev(i); //expected-note 0-1{{Iterator 'i' decremented by 1}} + //expected-note@-1 0-1{{Calling 'prev}} + //expected-note@Inputs/system-header-simulator-cxx.h:800 0-1{{Iterator 'it' decremented by 1}} + //expected-note@Inputs/system-header-simulator-cxx.h:800 0-1{{Calling 'advance}} + //expected-note@Inputs/system-header-simulator-cxx.h:800 0-1{{Passing the value -1 via 2nd parameter 'n'}} + //expected-note@Inputs/system-header-simulator-cxx.h:787 0-1{{Calling '__advance}} + //expected-note@Inputs/system-header-simulator-cxx.h:787 0-1{{Passing the value -1 via 2nd parameter 'n'}} + //expected-note@Inputs/system-header-simulator-cxx.h:775 0-1{{Iterator 'it' decremented by 1}} + //expected-note@Inputs/system-header-simulator-cxx.h:787 0-1{{Returning from '__advance}} + //expected-note@Inputs/system-header-simulator-cxx.h:800 0-1{{Returning from 'advance}} + //expected-note@-10 0-1{{Returning from 'prev}} clang_analyzer_express(clang_analyzer_iterator_position(j)); //expected-warning{{$v.end() - 1}} + //expected-note@-1{{$v.end() - 1}} } void std_prev2(const std::vector &v) { @@ -276,9 +408,20 @@ clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()"); - auto j = std::prev(i, 2); + auto j = std::prev(i, 2); //expected-note 0-1{{Iterator 'i' decremented by 2}} + //expected-note@-1 0-1{{Calling 'prev}} + //expected-note@Inputs/system-header-simulator-cxx.h:800 0-1{{Iterator 'it' decremented by 2}} + //expected-note@Inputs/system-header-simulator-cxx.h:800 0-1{{Calling 'advance}} + //expected-note@Inputs/system-header-simulator-cxx.h:800 0-1{{Passing the value -2 via 2nd parameter 'n'}} + //expected-note@Inputs/system-header-simulator-cxx.h:787 0-1{{Calling '__advance}} + //expected-note@Inputs/system-header-simulator-cxx.h:787 0-1{{Passing the value -2 via 2nd parameter 'n'}} + //expected-note@Inputs/system-header-simulator-cxx.h:775 0-1{{Iterator 'it' decremented by 2}} + //expected-note@Inputs/system-header-simulator-cxx.h:787 0-1{{Returning from '__advance}} + //expected-note@Inputs/system-header-simulator-cxx.h:800 0-1{{Returning from 'advance}} + //expected-note@-10 0-1{{Returning from 'prev}} clang_analyzer_express(clang_analyzer_iterator_position(j)); //expected-warning{{$v.end() - 2}} + //expected-note@-1{{$v.end() - 2}} } void std_next(const std::vector &v) { @@ -286,9 +429,21 @@ clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()"); - auto j = std::next(i); + auto j = std::next(i); //expected-note 0-1{{Iterator 'i' incremented by 1}} + //expected-note@-1 0-1{{Calling 'next}} + //expected-note@-2 0-1{{Passing the value 1 via 2nd parameter 'n'}} + //expected-note@Inputs/system-header-simulator-cxx.h:814 0-1{{Iterator 'it' incremented by 1}} + //expected-note@Inputs/system-header-simulator-cxx.h:814 0-1{{Calling 'advance}} + //expected-note@Inputs/system-header-simulator-cxx.h:814 0-1{{Passing the value 1 via 2nd parameter 'n'}} + //expected-note@Inputs/system-header-simulator-cxx.h:787 0-1{{Calling '__advance}} + //expected-note@Inputs/system-header-simulator-cxx.h:787 0-1{{Passing the value 1 via 2nd parameter 'n'}} + //expected-note@Inputs/system-header-simulator-cxx.h:775 0-1{{Iterator 'it' incremented by 1}} + //expected-note@Inputs/system-header-simulator-cxx.h:787 0-1{{Returning from '__advance}} + //expected-note@Inputs/system-header-simulator-cxx.h:814 0-1{{Returning from 'advance}} + //expected-note@-11 0-1{{Returning from 'next}} clang_analyzer_express(clang_analyzer_iterator_position(j)); //expected-warning{{$v.begin() + 1}} + //expected-note@-1{{$v.begin() + 1}} } void std_next2(const std::vector &v) { @@ -296,9 +451,21 @@ clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()"); - auto j = std::next(i, 2); + auto j = std::next(i, 2); //expected-note 0-1{{Iterator 'i' incremented by 2}} + //expected-note@-1 0-1{{Calling 'next}} + //expected-note@-2 0-1{{Passing the value 2 via 2nd parameter 'n'}} + //expected-note@Inputs/system-header-simulator-cxx.h:814 0-1{{Iterator 'it' incremented by 2}} + //expected-note@Inputs/system-header-simulator-cxx.h:814 0-1{{Calling 'advance}} + //expected-note@Inputs/system-header-simulator-cxx.h:814 0-1{{Passing the value 2 via 2nd parameter 'n'}} + //expected-note@Inputs/system-header-simulator-cxx.h:787 0-1{{Calling '__advance}} + //expected-note@Inputs/system-header-simulator-cxx.h:787 0-1{{Passing the value 2 via 2nd parameter 'n'}} + //expected-note@Inputs/system-header-simulator-cxx.h:775 0-1{{Iterator 'it' incremented by 2}} + //expected-note@Inputs/system-header-simulator-cxx.h:787 0-1{{Returning from '__advance}} + //expected-note@Inputs/system-header-simulator-cxx.h:814 0-1{{Returning from 'advance}} + //expected-note@-11 0-1{{Returning from 'next}} clang_analyzer_express(clang_analyzer_iterator_position(j)); //expected-warning{{$v.begin() + 2}} + //expected-note@-1{{$v.begin() + 2}} } //////////////////////////////////////////////////////////////////////////////// @@ -312,36 +479,45 @@ void list_copy_assignment(std::list &L1, const std::list &L2) { auto i0 = L1.cbegin(); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} L1 = L2; clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} } void vector_copy_assignment(std::vector &V1, const std::vector &V2) { auto i0 = V1.cbegin(); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} V1 = V2; clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} } void deque_copy_assignment(std::deque &D1, const std::deque &D2) { auto i0 = D1.cbegin(); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} D1 = D2; clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} } void forward_list_copy_assignment(std::forward_list &FL1, const std::forward_list &FL2) { auto i0 = FL1.cbegin(); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} FL1 = FL2; clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} } // Move void list_move_assignment(std::list &L1, std::list &L2) { auto i0 = L1.cbegin(), i1 = L2.cbegin(), i2 = --L2.cend(), i3 = L2.cend(); + // expected-note@-1 7{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(L2), "$L2.begin()"); clang_analyzer_denote(clang_analyzer_container_end(L2), "$L2.end()"); @@ -349,50 +525,73 @@ L1 = std::move(L2); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i3)); //expected-warning{{TRUE}} FIXME: Should be FALSE. + //expected-note@-1{{TRUE}} FIXME: Should be FALSE. clang_analyzer_eval(clang_analyzer_iterator_container(i1) == &L1); // expected-warning{{TRUE}} + // expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &L1); // expected-warning{{TRUE}} + // expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$L2.begin()}} + // expected-note@-1{{$L2.begin()}} } void vector_move_assignment(std::vector &V1, std::vector &V2) { auto i0 = V1.cbegin(), i1 = V2.cbegin(), i2 = --V2.cend(), i3 = V2.cend(); + // expected-note@-1 7{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(V2), "$V2.begin()"); V1 = std::move(V2); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i3)); //expected-warning{{TRUE}} FIXME: Should be FALSE. + //expected-note@-1{{TRUE}} FIXME: Should be FALSE. clang_analyzer_eval(clang_analyzer_iterator_container(i1) == &V1); // expected-warning{{TRUE}} + // expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &V1); // expected-warning{{TRUE}} + // expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$V2.begin()}} + // expected-note@-1{{$V2.begin()}} } void deque_move_assignment(std::deque &D1, std::deque &D2) { auto i0 = D1.cbegin(), i1 = D2.cbegin(), i2 = --D2.cend(), i3 = D2.cend(); + // expected-note@-1 7{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(D2), "$D2.begin()"); D1 = std::move(D2); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i3)); //expected-warning{{TRUE}} FIXME: Should be FALSE. + //expected-note@-1{{TRUE}} FIXME: Should be FALSE. clang_analyzer_eval(clang_analyzer_iterator_container(i1) == &D1); // expected-warning{{TRUE}} + // expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &D1); // expected-warning{{TRUE}} + // expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$D2.begin()}} + // expected-note@-1{{$D2.begin()}} } void forward_list_move_assignment(std::forward_list &FL1, @@ -404,12 +603,17 @@ FL1 = std::move(FL2); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} FIXME: Should be FALSE. + //expected-note@-1{{TRUE}} FIXME: Should be FALSE. clang_analyzer_eval(clang_analyzer_iterator_container(i1) == &FL1); // expected-warning{{TRUE}} + // expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$FL2.begin()}} + // expected-note@-1{{$FL2.begin()}} } @@ -428,28 +632,36 @@ auto i0 = L.cbegin(), i1 = L.cend(); L.assign(10, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} } void vector_assign(std::vector &V, int n) { auto i0 = V.cbegin(), i1 = V.cend(); V.assign(10, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} } void deque_assign(std::deque &D, int n) { auto i0 = D.cbegin(), i1 = D.cend(); D.assign(10, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} } void forward_list_assign(std::forward_list &FL, int n) { auto i0 = FL.cbegin(), i1 = FL.cend(); FL.assign(10, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} } /// clear() @@ -460,29 +672,37 @@ void list_clear(std::list &L) { auto i0 = L.cbegin(), i1 = L.cend(); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} L.clear(); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} } void vector_clear(std::vector &V) { auto i0 = V.cbegin(), i1 = V.cend(); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} V.clear(); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} } void deque_clear(std::deque &D) { auto i0 = D.cbegin(), i1 = D.cend(); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} D.clear(); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} } void forward_list_clear(std::forward_list &FL) { auto i0 = FL.cbegin(), i1 = FL.cend(); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} FL.clear(); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} } /// push_back() @@ -496,6 +716,7 @@ void list_push_back(std::list &L, int n) { auto i0 = L.cbegin(), i1 = --L.cend(), i2 = L.cend(); + // expected-note@-1 6{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(L), "$L.begin()"); clang_analyzer_denote(clang_analyzer_container_end(L), "$L.end()"); @@ -503,18 +724,25 @@ L.push_back(n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$L.begin()}} + // expected-note@-1{{$L.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$L.end() - 1}} + // expected-note@-1{{$L.end() - 1}} clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$L.end()}} FIXME: Should be $L.end() + 1 + // expected-note@-1{{$L.end()}} FIXME: Should be $L.end() + 1 } /// std::vector-like containers: The past-the-end iterator is invalidated. void vector_push_back(std::vector &V, int n) { auto i0 = V.cbegin(), i1 = --V.cend(), i2 = V.cend(); + // expected-note@-1 5{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()"); clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()"); @@ -522,11 +750,16 @@ V.push_back(n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$V.begin()}} + // expected-note@-1{{$V.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$V.end() - 1}} + // expected-note@-1{{$V.end() - 1}} } /// std::deque-like containers: All iterators, including the past-the-end @@ -534,6 +767,7 @@ void deque_push_back(std::deque &D, int n) { auto i0 = D.cbegin(), i1 = --D.cend(), i2 = D.cend(); + // expected-note@-1 3{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(D), "$D.begin()"); clang_analyzer_denote(clang_analyzer_container_end(D), "$D.end()"); @@ -541,8 +775,11 @@ D.push_back(n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} } /// emplace_back() @@ -556,6 +793,7 @@ void list_emplace_back(std::list &L, int n) { auto i0 = L.cbegin(), i1 = --L.cend(), i2 = L.cend(); + // expected-note@-1 6{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(L), "$L.begin()"); clang_analyzer_denote(clang_analyzer_container_end(L), "$L.end()"); @@ -563,18 +801,25 @@ L.emplace_back(n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$L.begin()}} + // expected-note@-1{{$L.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$L.end()}} + // expected-note@-1{{$L.end()}} clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$L.end()}} FIXME: Should be $L.end() + 1 + // expected-note@-1{{$L.end()}} FIXME: Should be $L.end() + 1 } /// std::vector-like containers: The past-the-end iterator is invalidated. void vector_emplace_back(std::vector &V, int n) { auto i0 = V.cbegin(), i1 = --V.cend(), i2 = V.cend(); + // expected-note@-1 5{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()"); clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()"); @@ -582,11 +827,16 @@ V.emplace_back(n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$V.begin()}} + // expected-note@-1{{$V.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$V.end() - 1}} + // expected-note@-1{{$V.end() - 1}} } /// std::deque-like containers: All iterators, including the past-the-end @@ -594,6 +844,7 @@ void deque_emplace_back(std::deque &D, int n) { auto i0 = D.cbegin(), i1 = --D.cend(), i2 = D.cend(); + // expected-note@-1 3{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(D), "$D.begin()"); clang_analyzer_denote(clang_analyzer_container_end(D), "$D.end()"); @@ -601,8 +852,11 @@ D.emplace_back(n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} } /// pop_back() @@ -616,6 +870,7 @@ void list_pop_back(std::list &L, int n) { auto i0 = L.cbegin(), i1 = --L.cend(), i2 = L.cend(); + // expected-note@-1 5{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(L), "$L.begin()"); clang_analyzer_denote(clang_analyzer_container_end(L), "$L.end()"); @@ -623,11 +878,16 @@ L.pop_back(); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$L.begin()}} + // expected-note@-1{{$L.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$L.end()}} FIXME: Should be $L.end() - 1 + // expected-note@-1{{$L.end()}} FIXME: Should be $L.end() - 1 } /// std::vector-like containers: Iterators to the last element, as well as the @@ -635,6 +895,7 @@ void vector_pop_back(std::vector &V, int n) { auto i0 = V.cbegin(), i1 = --V.cend(), i2 = V.cend(); + // expected-note@-1 4{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()"); clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()"); @@ -642,10 +903,14 @@ V.pop_back(); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$V.begin()}} + // expected-note@-1{{$V.begin()}} } /// std::deque-like containers: Iterators to the last element are invalidated. @@ -654,6 +919,7 @@ void deque_pop_back(std::deque &D, int n) { auto i0 = D.cbegin(), i1 = --D.cend(), i2 = D.cend(); + // expected-note@-1 4{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(D), "$D.begin()"); clang_analyzer_denote(clang_analyzer_container_end(D), "$D.end()"); @@ -661,10 +927,14 @@ D.pop_back(); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$D.begin()}} + // expected-note@-1{{$D.begin()}} } /// push_front() @@ -685,10 +955,14 @@ L.push_front(n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$L.begin()}} + // expected-note@-1{{$L.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$L.end()}} + // expected-note@-1{{$L.end()}} } /// std::deque-like containers: All iterators, including the past-the-end @@ -696,6 +970,7 @@ void deque_push_front(std::deque &D, int n) { auto i0 = D.cbegin(), i1 = --D.cend(), i2 = D.cend(); + // expected-note@-1 3{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(D), "$D.begin()"); clang_analyzer_denote(clang_analyzer_container_end(D), "$D.end()"); @@ -703,8 +978,11 @@ D.push_front(n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} } /// std::forward_list-like containers: No iterators are invalidated. @@ -718,10 +996,14 @@ FL.push_front(n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$FL.begin()}} + // expected-note@-1{{$FL.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$FL.end()}} + // expected-note@-1{{$FL.end()}} } /// emplace_front() @@ -742,10 +1024,14 @@ L.emplace_front(n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$L.begin()}} + // expected-note@-1{{$L.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$L.end()}} + // expected-note@-1{{$L.end()}} } /// std::deque-like containers: All iterators, including the past-the-end @@ -753,6 +1039,7 @@ void deque_emplace_front(std::deque &D, int n) { auto i0 = D.cbegin(), i1 = --D.cend(), i2 = D.cend(); + // expected-note@-1 3{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(D), "$D.begin()"); clang_analyzer_denote(clang_analyzer_container_end(D), "$D.end()"); @@ -760,8 +1047,11 @@ D.emplace_front(n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} } /// std::forward_list-like containers: No iterators are invalidated. @@ -775,10 +1065,14 @@ FL.emplace_front(n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$FL.begin()}} + // expected-note@-1{{$FL.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$FL.end()}} + // expected-note@-1{{$FL.end()}} } /// pop_front() @@ -792,6 +1086,7 @@ void list_pop_front(std::list &L, int n) { auto i0 = L.cbegin(), i1 = ++L.cbegin(), i2 = L.cend(); + // expected-note@-1 5{{Iterator incremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(L), "$L.begin()"); clang_analyzer_denote(clang_analyzer_container_end(L), "$L.end()"); @@ -799,11 +1094,16 @@ L.pop_front(); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$L.begin() + 1}} + // expected-note@-1{{$L.begin() + 1}} clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$L.end()}} + // expected-note@-1{{$L.end()}} } /// std::deque-like containers: Iterators to the first element are invalidated. @@ -811,6 +1111,7 @@ void deque_pop_front(std::deque &D, int n) { auto i0 = D.cbegin(), i1 = ++D.cbegin(), i2 = D.cend(); + // expected-note@-1 5{{Iterator incremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(D), "$D.begin()"); clang_analyzer_denote(clang_analyzer_container_end(D), "$D.end()"); @@ -818,11 +1119,16 @@ D.pop_front(); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$D.begin() + 1}} + // expected-note@-1{{$D.begin() + 1}} clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$D.end()}} + // expected-note@-1{{$D.end()}} } /// std::forward_list-like containers: Iterators to the first element are @@ -830,6 +1136,7 @@ void forward_list_pop_front(std::list &FL, int n) { auto i0 = FL.cbegin(), i1 = ++FL.cbegin(), i2 = FL.cend(); + // expected-note@-1 5{{Iterator incremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(FL), "$FL.begin()"); clang_analyzer_denote(clang_analyzer_container_end(FL), "$FL.end()"); @@ -837,11 +1144,16 @@ FL.pop_front(); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$FL.begin() + 1}} + // expected-note@-1{{$FL.begin() + 1}} clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$FL.end()}} + // expected-note@-1{{$FL.end()}} } /// insert() @@ -865,15 +1177,20 @@ auto i2 = L.insert(i0, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$L.begin()}} + // expected-note@-1{{$L.begin()}} // clang_analyzer_express(clang_analyzer_iterator_position(i2)); FIXME: expect warning $L.begin() - 1 clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$L.end()}} + // expected-note@-1{{$L.end()}} } void list_insert_behind_begin(std::list &L, int n) { auto i0 = L.cbegin(), i1 = ++L.cbegin(), i2 = L.cend(); + // expected-note@-1 6{{Iterator incremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(L), "$L.begin()"); clang_analyzer_denote(clang_analyzer_container_end(L), "$L.end()"); @@ -881,13 +1198,19 @@ auto i3 = L.insert(i1, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$L.begin()}} FIXME: Should be $L.begin() - 1 + // expected-note@-1{{$L.begin()}} FIXME: Should be $L.begin() - 1 clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$L.begin() + 1}} + // expected-note@-1{{$L.begin() + 1}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $L.begin() clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$L.end()}} + // expected-note@-1{{$L.end()}} } template Iter return_any_iterator(const Iter &It); @@ -902,17 +1225,24 @@ auto i3 = L.insert(i1, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$L.begin()}} + // expected-note@-1{{$L.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$i1}} + // expected-note@-1{{$i1}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $i - 1 clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$L.end()}} + // expected-note@-1{{$L.end()}} } void list_insert_ahead_of_end(std::list &L, int n) { auto i0 = L.cbegin(), i1 = --L.cend(), i2 = L.cend(); + // expected-note@-1 6{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(L), "$L.begin()"); clang_analyzer_denote(clang_analyzer_container_end(L), "$L.end()"); @@ -920,17 +1250,24 @@ auto i3 = L.insert(i1, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$L.begin()}} + // expected-note@-1{{$L.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$L.end() - 1}} + // expected-note@-1{{$L.end() - 1}} clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$L.end()}} + // expected-note@-1{{$L.end()}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $L.end() - 2 } void list_insert_end(std::list &L, int n) { auto i0 = L.cbegin(), i1 = --L.cend(), i2 = L.cend(); + // expected-note@-1 6{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(L), "$L.begin()"); clang_analyzer_denote(clang_analyzer_container_end(L), "$L.end()"); @@ -938,12 +1275,18 @@ auto i3 = L.insert(i2, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$L.begin()}} + // expected-note@-1{{$L.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$L.end() - 1}} FIXME: should be $L.end() - 2 + // expected-note@-1{{$L.end() - 1}} FIXME: should be $L.end() - 2 clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$L.end()}} + // expected-note@-1{{$L.end()}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $L.end() - 1 } @@ -960,13 +1303,16 @@ auto i2 = V.insert(i0, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} // clang_analyzer_express(clang_analyzer_iterator_position(i2)); FIXME: expect warning $V.begin() - 1 } void vector_insert_behind_begin(std::vector &V, int n) { auto i0 = V.cbegin(), i1 = ++V.cbegin(), i2 = V.cend(); + // expected-note@-1 4{{Iterator incremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()"); clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()"); @@ -974,10 +1320,14 @@ auto i3 = V.insert(i1, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$V.begin()}} FIXME: Should be $V.begin() - 1 + // expected-note@-1{{$V.begin()}} FIXME: Should be $V.begin() - 1 // clang_analyzer_express(clang_analyzer_iterator_position(i3)); // FIXME: expect -warning $V.begin() } @@ -991,15 +1341,20 @@ auto i3 = V.insert(i1, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$V.begin()}} + // expected-note@-1{{$V.begin()}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expecte warning $i1 - 1 } void vector_insert_ahead_of_end(std::vector &V, int n) { auto i0 = V.cbegin(), i1 = --V.cend(), i2 = V.cend(); + // expected-note@-1 4{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()"); clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()"); @@ -1007,15 +1362,20 @@ auto i3 = V.insert(i1, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$V.begin()}} + // expected-note@-1{{$V.begin()}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $V.end() - 2 } void vector_insert_end(std::vector &V, int n) { auto i0 = V.cbegin(), i1 = --V.cend(), i2 = V.cend(); + // expected-note@-1 5{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()"); clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()"); @@ -1023,11 +1383,16 @@ auto i3 = V.insert(i2, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$V.begin()}} + // expected-note@-1{{$V.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$V.end() - 1}} FIXME: Should be $V.end() - 2 + // expected-note@-1{{$V.end() - 1}} FIXME: Should be $V.end() - 2 // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $V.end() - 1 } @@ -1043,13 +1408,16 @@ auto i2 = D.insert(i0, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} // clang_analyzer_express(clang_analyzer_iterator_position(i2)); FIXME: expect warning $D.begin() - 1 } void deque_insert_behind_begin(std::deque &D, int n) { auto i0 = D.cbegin(), i1 = ++D.cbegin(), i2 = D.cend(); + // expected-note@-1 3{{Iterator incremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(D), "$D.begin()"); clang_analyzer_denote(clang_analyzer_container_end(D), "$D.end()"); @@ -1057,8 +1425,11 @@ auto i3 = D.insert(i1, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $D.begin() - 1 } @@ -1073,14 +1444,18 @@ auto i3 = D.insert(i1, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $i1 - 1 } void deque_insert_ahead_of_end(std::deque &D, int n) { auto i0 = D.cbegin(), i1 = --D.cend(), i2 = D.cend(); + // expected-note@-1 3{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(D), "$D.begin()"); clang_analyzer_denote(clang_analyzer_container_end(D), "$D.end()"); @@ -1088,14 +1463,18 @@ auto i3 = D.insert(i1, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $D.end() - 2 } void deque_insert_end(std::deque &D, int n) { auto i0 = D.cbegin(), i1 = --D.cend(), i2 = D.cend(); + // expected-note@-1 3{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(D), "$D.begin()"); clang_analyzer_denote(clang_analyzer_container_end(D), "$D.end()"); @@ -1103,8 +1482,11 @@ auto i3 = D.insert(i2, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $D.end() - 1 } @@ -1128,15 +1510,20 @@ auto i2 = FL.insert_after(i0, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$FL.begin()}} + // expected-note@-1{{$FL.begin()}} // clang_analyzer_express(clang_analyzer_iterator_position(i2)); FIXME: expect warning $FL.begin() + 1 clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$FL.end()}} + // expected-note@-1{{$FL.end()}} } void forward_list_insert_after_behind_begin(std::forward_list &FL, int n) { auto i0 = FL.cbegin(), i1 = ++FL.cbegin(), i2 = FL.cend(); + // expected-note@-1 6{{Iterator incremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(FL), "$FL.begin()"); clang_analyzer_denote(clang_analyzer_container_end(FL), "$FL.end()"); @@ -1144,13 +1531,19 @@ auto i3 = FL.insert_after(i1, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$FL.begin()}} + // expected-note@-1{{$FL.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$FL.begin() + 1}} + // expected-note@-1{{$FL.begin() + 1}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $FL.begin() + 2 clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$FL.end()}} + // expected-note@-1{{$FL.end()}} } void forward_list_insert_after_unknown(std::forward_list &FL, int n) { @@ -1163,13 +1556,19 @@ auto i3 = FL.insert_after(i1, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$FL.begin()}} + // expected-note@-1{{$FL.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$i1}} + // expected-note@-1{{$i1}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $i1 + 1 clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$FL.end()}} + // expected-note@-1{{$FL.end()}} } /// emplace() @@ -1193,15 +1592,20 @@ auto i2 = L.emplace(i0, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$L.begin()}} + // expected-note@-1{{$L.begin()}} // clang_analyzer_express(clang_analyzer_iterator_position(i2)); FIXME: expect warning $L.begin() - 1 clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$L.end()}} + // expected-note@-1{{$L.end()}} } void list_emplace_behind_begin(std::list &L, int n) { auto i0 = L.cbegin(), i1 = ++L.cbegin(), i2 = L.cend(); + // expected-note@-1 6{{Iterator incremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(L), "$L.begin()"); clang_analyzer_denote(clang_analyzer_container_end(L), "$L.end()"); @@ -1209,13 +1613,19 @@ auto i3 = L.emplace(i1, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$L.begin()}} FIXME: Should be $L.begin() - 1 + // expected-note@-1{{$L.begin()}} FIXME: Should be $L.begin() - 1 clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$L.begin() + 1}} + // expected-note@-1{{$L.begin() + 1}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $L.begin() clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$L.end()}} + // expected-note@-1{{$L.end()}} } template Iter return_any_iterator(const Iter &It); @@ -1230,17 +1640,24 @@ auto i3 = L.emplace(i1, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$L.begin()}} + // expected-note@-1{{$L.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$i1}} + // expected-note@-1{{$i1}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $i - 1 clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$L.end()}} + // expected-note@-1{{$L.end()}} } void list_emplace_ahead_of_end(std::list &L, int n) { auto i0 = L.cbegin(), i1 = --L.cend(), i2 = L.cend(); + // expected-note@-1 6{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(L), "$L.begin()"); clang_analyzer_denote(clang_analyzer_container_end(L), "$L.end()"); @@ -1248,17 +1665,24 @@ auto i3 = L.emplace(i1, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$L.begin()}} + // expected-note@-1{{$L.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$L.end() - 1}} + // expected-note@-1{{$L.end() - 1}} clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$L.end()}} + // expected-note@-1{{$L.end()}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $L.end() - 2 } void list_emplace_end(std::list &L, int n) { auto i0 = L.cbegin(), i1 = --L.cend(), i2 = L.cend(); + // expected-note@-1 6{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(L), "$L.begin()"); clang_analyzer_denote(clang_analyzer_container_end(L), "$L.end()"); @@ -1266,12 +1690,18 @@ auto i3 = L.emplace(i2, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$L.begin()}} + // expected-note@-1{{$L.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$L.end() - 1}} FIXME: should be $L.end() - 2 + // expected-note@-1{{$L.end() - 1}} FIXME: should be $L.end() - 2 clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$L.end()}} + // expected-note@-1{{$L.end()}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $L.end() - 1 } @@ -1288,12 +1718,15 @@ auto i2 = V.emplace(i0, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} // clang_analyzer_express(clang_analyzer_iterator_position(i2)); FIXME: expect warning $V.begin() - 1 } void vector_emplace_behind_begin(std::vector &V, int n) { auto i0 = V.cbegin(), i1 = ++V.cbegin(), i2 = V.cend(); + // expected-note@-1 4{{Iterator incremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()"); clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()"); @@ -1301,10 +1734,14 @@ auto i3 = V.emplace(i1, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$V.begin()}} FIXME: Should be $V.begin() - 1 + // expected-note@-1{{$V.begin()}} FIXME: Should be $V.begin() - 1 // clang_analyzer_express(clang_analyzer_iterator_position(i3)); // FIXME: expect -warning $V.begin() } @@ -1318,15 +1755,20 @@ auto i3 = V.emplace(i1, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$V.begin()}} + // expected-note@-1{{$V.begin()}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expecte warning $i1 - 1 } void vector_emplace_ahead_of_end(std::vector &V, int n) { auto i0 = V.cbegin(), i1 = --V.cend(), i2 = V.cend(); + // expected-note@-1 4{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()"); clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()"); @@ -1334,15 +1776,20 @@ auto i3 = V.emplace(i1, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$V.begin()}} + // expected-note@-1{{$V.begin()}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $V.end() - 2 } void vector_emplace_end(std::vector &V, int n) { auto i0 = V.cbegin(), i1 = --V.cend(), i2 = V.cend(); + // expected-note@-1 5{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()"); clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()"); @@ -1350,11 +1797,16 @@ auto i3 = V.emplace(i2, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$V.begin()}} + // expected-note@-1{{$V.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$V.end() - 1}} FIXME: Should be $V.end() - 2 + // expected-note@-1{{$V.end() - 1}} FIXME: Should be $V.end() - 2 // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $V.end() - 1 } @@ -1370,12 +1822,15 @@ auto i2 = D.emplace(i0, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} // clang_analyzer_express(clang_analyzer_iterator_position(i2)); FIXME: expect warning $D.begin() - 1 } void deque_emplace_behind_begin(std::deque &D, int n) { auto i0 = D.cbegin(), i1 = ++D.cbegin(), i2 = D.cend(); + // expected-note@-1 3{{Iterator incremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(D), "$D.begin()"); clang_analyzer_denote(clang_analyzer_container_end(D), "$D.end()"); @@ -1383,8 +1838,11 @@ auto i3 = D.emplace(i1, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $D.begin() - 1 } @@ -1398,14 +1856,18 @@ auto i3 = D.emplace(i1, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $i1 - 1 } void deque_emplace_ahead_of_end(std::deque &D, int n) { auto i0 = D.cbegin(), i1 = --D.cend(), i2 = D.cend(); + // expected-note@-1 3{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(D), "$D.begin()"); clang_analyzer_denote(clang_analyzer_container_end(D), "$D.end()"); @@ -1413,14 +1875,18 @@ auto i3 = D.emplace(i1, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $D.end() - 2 } void deque_emplace_end(std::deque &D, int n) { auto i0 = D.cbegin(), i1 = --D.cend(), i2 = D.cend(); + // expected-note@-1 3{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(D), "$D.begin()"); clang_analyzer_denote(clang_analyzer_container_end(D), "$D.end()"); @@ -1428,8 +1894,11 @@ auto i3 = D.emplace(i2, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $D.end() - 1 } @@ -1453,16 +1922,21 @@ auto i2 = FL.emplace_after(i0, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$FL.begin()}} + // expected-note@-1{{$FL.begin()}} // clang_analyzer_express(clang_analyzer_iterator_position(i2)); FIXME: expect warning $FL.begin() + 1 clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$FL.end()}} + // expected-note@-1{{$FL.end()}} } void forward_list_emplace_after_behind_begin(std::forward_list &FL, int n) { auto i0 = FL.cbegin(), i1 = ++FL.cbegin(), i2 = FL.cend(); + // expected-note@-1 6{{Iterator incremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(FL), "$FL.begin()"); clang_analyzer_denote(clang_analyzer_container_end(FL), "$FL.end()"); @@ -1470,13 +1944,19 @@ auto i3 = FL.emplace_after(i1, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$FL.begin()}} + // expected-note@-1{{$FL.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$FL.begin() + 1}} + // expected-note@-1{{$FL.begin() + 1}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $FL.begin() + 2 clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$FL.end()}} + // expected-note@-1{{$FL.end()}} } void forward_list_emplace_after_unknown(std::forward_list &FL, int n) { @@ -1489,13 +1969,19 @@ auto i3 = FL.emplace_after(i1, n); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$FL.begin()}} + // expected-note@-1{{$FL.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$i1}} + // expected-note@-1{{$i1}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $i1 + 1 clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$FL.end()}} + // expected-note@-1{{$FL.end()}} } /// erase() @@ -1513,6 +1999,7 @@ void list_erase_begin(std::list &L) { auto i0 = L.cbegin(), i1 = ++L.cbegin(), i2 = L.cend(); + // expected-note@-1 5{{Iterator incremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(L), "$L.begin()"); clang_analyzer_denote(clang_analyzer_container_end(L), "$L.end()"); @@ -1520,16 +2007,22 @@ auto i3 = L.erase(i0); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$L.begin() + 1}} + // expected-note@-1{{$L.begin() + 1}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $L.begin() + 1 clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$L.end()}} + // expected-note@-1{{$L.end()}} } void list_erase_behind_begin(std::list &L, int n) { auto i0 = L.cbegin(), i1 = ++L.cbegin(), i2 = L.cend(); + // expected-note@-1 5{{Iterator incremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(L), "$L.begin()"); clang_analyzer_denote(clang_analyzer_container_end(L), "$L.end()"); @@ -1537,12 +2030,17 @@ auto i3 = L.erase(i1); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$L.begin()}} FIXME: Should be $L.begin() + 1 + // expected-note@-1{{$L.begin()}} FIXME: Should be $L.begin() + 1 // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $L.begin() + 2 clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$L.end()}} + // expected-note@-1{{$L.end()}} } void list_erase_unknown(std::list &L) { @@ -1555,16 +2053,22 @@ auto i3 = L.erase(i1); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$L.begin()}} + // expected-note@-1{{$L.begin()}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $i1 + 1 clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$L.end()}} + // expected-note@-1{{$L.end()}} } void list_erase_ahead_of_end(std::list &L) { auto i0 = L.cbegin(), i1 = --L.cend(), i2 = L.cend(); + // expected-note@-1 5{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(L), "$L.begin()"); clang_analyzer_denote(clang_analyzer_container_end(L), "$L.end()"); @@ -1572,11 +2076,16 @@ auto i3 = L.erase(i1); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$L.begin()}} + // expected-note@-1{{$L.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$L.end()}} + // expected-note@-1{{$L.end()}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $L.end() } @@ -1585,6 +2094,7 @@ void vector_erase_begin(std::vector &V) { auto i0 = V.cbegin(), i1 = ++V.cbegin(), i2 = V.cend(); + // expected-note@-1 3{{Iterator incremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()"); clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()"); @@ -1592,14 +2102,18 @@ auto i3 = V.erase(i0); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $V.begin() + 1 } void vector_erase_behind_begin(std::vector &V, int n) { auto i0 = V.cbegin(), i1 = ++V.cbegin(), i2 = V.cend(); + // expected-note@-1 4{{Iterator incremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()"); clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()"); @@ -1607,10 +2121,14 @@ auto i3 = V.erase(i1); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$V.begin()}} FIXME: Should be $V.begin() + 1 + // expected-note@-1{{$V.begin()}} FIXME: Should be $V.begin() + 1 // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $V.begin() + 2 } @@ -1624,15 +2142,20 @@ auto i3 = V.erase(i1); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$V.begin()}} + // expected-note@-1{{$V.begin()}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $i1 + 1 } void vector_erase_ahead_of_end(std::vector &V) { auto i0 = V.cbegin(), i1 = --V.cend(), i2 = V.cend(); + // expected-note@-1 4{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()"); clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()"); @@ -1640,10 +2163,14 @@ auto i3 = V.erase(i1); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$V.begin()}} + // expected-note@-1{{$V.begin()}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $V.end() } @@ -1657,6 +2184,7 @@ void deque_erase_begin(std::deque &D) { auto i0 = D.cbegin(), i1 = ++D.cbegin(), i2 = D.cend(); + // expected-note@-1 3{{Iterator incremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(D), "$D.begin()"); clang_analyzer_denote(clang_analyzer_container_end(D), "$D.end()"); @@ -1664,14 +2192,18 @@ auto i3 = D.erase(i0); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $D.begin() + 1 } void deque_erase_behind_begin(std::deque &D, int n) { auto i0 = D.cbegin(), i1 = ++D.cbegin(), i2 = D.cend(); + // expected-note@-1 3{{Iterator incremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(D), "$D.begin()"); clang_analyzer_denote(clang_analyzer_container_end(D), "$D.end()"); @@ -1679,8 +2211,11 @@ auto i3 = D.erase(i1); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $D.begin() + 2 } @@ -1695,14 +2230,18 @@ auto i3 = D.erase(i1); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $i1 + 1 } void deque_erase_ahead_of_end(std::deque &D) { auto i0 = D.cbegin(), i1 = --D.cend(), i2 = D.cend(); + // expected-note@-1 3{{Iterator decremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(D), "$D.begin()"); clang_analyzer_denote(clang_analyzer_container_end(D), "$D.end()"); @@ -1710,8 +2249,11 @@ auto i3 = D.erase(i1); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $D.end() } @@ -1731,7 +2273,9 @@ void forward_list_erase_after_begin(std::forward_list &FL) { auto i0 = FL.cbegin(), i1 = ++FL.cbegin(), i2 = i1, i3 = FL.cend(); + // expected-note@-1 7{{Iterator incremented by 1}} ++i2; + // expected-note@-1 7{{Iterator 'i2' incremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(FL), "$FL.begin()"); clang_analyzer_denote(clang_analyzer_container_end(FL), "$FL.end()"); @@ -1739,22 +2283,32 @@ auto i4 = FL.erase_after(i0); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i3)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$FL.begin()}} + // expected-note@-1{{$FL.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$FL.begin() + 2}} FIXME: Should be $FL.begin() + 1 + // expected-note@-1{{$FL.begin() + 2}} FIXME: Should be $FL.begin() + 1 // clang_analyzer_express(clang_analyzer_iterator_position(i4)); FIXME: expect warning $FL.begin() + 1 clang_analyzer_express(clang_analyzer_iterator_position(i3)); // expected-warning{{$FL.end()}} + // expected-note@-1{{$FL.end()}} } void forward_list_erase_after_unknown(std::forward_list &FL) { auto i0 = FL.cbegin(), i1 = return_any_iterator(FL.cbegin()), i2 = i1, i3 = i1, i4 = FL.cend(); ++i2; + // expected-note@-1 9{{Iterator 'i2' incremented by 1}} ++i3; + // expected-note@-1 9{{Iterator 'i3' incremented by 1}} ++i3; + // expected-note@-1 9{{Iterator 'i3' incremented by 1}} clang_analyzer_denote(clang_analyzer_container_begin(FL), "$FL.begin()"); clang_analyzer_denote(clang_analyzer_container_end(FL), "$FL.end()"); @@ -1763,16 +2317,25 @@ auto i5 = FL.erase_after(i1); clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{FALSE}} + //expected-note@-1{{FALSE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i3)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_eval(clang_analyzer_iterator_validity(i4)); //expected-warning{{TRUE}} + //expected-note@-1{{TRUE}} clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$FL.begin()}} + // expected-note@-1{{$FL.begin()}} clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$i1}} + // expected-note@-1{{$i1}} clang_analyzer_express(clang_analyzer_iterator_position(i3)); // expected-warning{{$i1 + 2}} FIXME: Should be $i1 + 1 + // expected-note@-1{{$i1 + 2}} FIXME: Should be $i1 + 1 // clang_analyzer_express(clang_analyzer_iterator_position(i5)); FIXME: expect warning $i1 + 1 clang_analyzer_express(clang_analyzer_iterator_position(i4)); // expected-warning{{$FL.end()}} + // expected-note@-1{{$FL.end()}} } struct simple_iterator_base { @@ -1820,21 +2383,24 @@ void deferred_assumption(std::vector &V, int e) { const auto first = V.begin(); const auto comp1 = (first != V.end()), comp2 = (first == V.end()); - if (comp1) { + if (comp1) { // expected-note{{'comp1' is true}} + // expected-note@-1{{Taking true branch}} clang_analyzer_eval(clang_analyzer_container_end(V) == clang_analyzer_iterator_position(first)); // expected-warning@-1{{FALSE}} + // expected-note@-2{{FALSE}} } } void loop(std::vector &V, int e) { auto start = V.begin(); - while (true) { + while (true) { // expected-note{{Loop condition is true. Entering loop body}} auto item = std::find(start, V.end(), e); - if (item == V.end()) + if (item == V.end()) // expected-note{{Taking false branch}} break; clang_analyzer_eval(clang_analyzer_container_end(V) == clang_analyzer_iterator_position(item)); // expected-warning@-1{{FALSE}} + // expected-note@-2{{FALSE}} } } @@ -1853,12 +2419,48 @@ auto first = nonStdFind(V.begin(), V.end(), e); clang_analyzer_eval(clang_analyzer_container_end(V) == clang_analyzer_iterator_position(first)); // expected-warning@-1{{FALSE}} expected-warning@-1{{TRUE}} - if (V.end() != first) { + // expected-note@-2{{FALSE}} expected-note@-2{{TRUE}} + // expected-note@-3 2{{Assuming the condition is false}} + // expected-note@-4{{Assuming the condition is true}} + if (V.end() != first) { // expected-note{{Taking true branch}} + clang_analyzer_eval(clang_analyzer_container_end(V) == clang_analyzer_iterator_position(first)); // expected-warning@-1{{FALSE}} + // expected-note@-2{{FALSE}} } } +/// Track the right iterators only + +void prefix_increment2(const std::vector &v) { + auto i = v.begin(), j = v.begin(); + + clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()"); + + auto k = ++j; // expected-note 2{{Iterator 'j' incremented by 1}} + // FIXME: Expect only one note. + + clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.begin()}} + //expected-note@-1{{$v.begin()}} + + clang_analyzer_express(clang_analyzer_iterator_position(k)); //expected-warning{{$v.begin() + 1}} + //expected-note@-1{{$v.begin() + 1}} +} + +void prefix_increment3(const std::vector &v) { + auto i = v.begin(), j = v.begin(); + + clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()"); + + auto k = ++j; // expected-note{{Iterator 'j' incremented by 1}} + // FIXME: expect no note. + + clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.begin()}} + //expected-note@-1{{$v.begin()}} +} + +/// Print State + void clang_analyzer_printState(); void print_state(std::vector &V) { Index: clang/test/Analysis/iterator-range.cpp =================================================================== --- clang/test/Analysis/iterator-range.cpp +++ clang/test/Analysis/iterator-range.cpp @@ -1,5 +1,14 @@ -// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false %s -verify -// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify +// RUN: %clang_analyze_cc1 -std=c++11\ +// RUN: -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange\ +// RUN: -analyzer-config aggressive-binary-operation-simplification=true\ +// RUN: -analyzer-config c++-container-inlining=false -analyzer-output=text %s\ +// RUN: -verify + +// RUN: %clang_analyze_cc1 -std=c++11\ +// RUN: -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange\ +// RUN: -analyzer-config aggressive-binary-operation-simplification=true\ +// RUN: -analyzer-config c++-container-inlining=true -DINLINE=1\ +// RUN: -analyzer-output=text %s -verify #include "Inputs/system-header-simulator-cxx.h" @@ -32,6 +41,7 @@ void deref_end(const std::vector &V) { auto i = V.end(); *i; // expected-warning{{Past-the-end iterator dereferenced}} + // expected-note@-1{{Past-the-end iterator dereferenced}} } // Prefix increment - operator++() @@ -59,6 +69,7 @@ void incr_end(const std::vector &V) { auto i = V.end(); ++i; // expected-warning{{Iterator incremented behind the past-the-end iterator}} + // expected-note@-1{{Iterator incremented behind the past-the-end iterator}} } // Postfix increment - operator++(int) @@ -86,6 +97,7 @@ void end_incr(const std::vector &V) { auto i = V.end(); i++; // expected-warning{{Iterator incremented behind the past-the-end iterator}} + // expected-note@-1{{Iterator incremented behind the past-the-end iterator}} } // Prefix decrement - operator--() @@ -93,6 +105,7 @@ void decr_begin(const std::vector &V) { auto i = V.begin(); --i; // expected-warning{{Iterator decremented ahead of its valid range}} + // expected-note@-1{{Iterator decremented ahead of its valid range}} } void decr_behind_begin(const std::vector &V) { @@ -120,6 +133,7 @@ void begin_decr(const std::vector &V) { auto i = V.begin(); i--; // expected-warning{{Iterator decremented ahead of its valid range}} + // expected-note@-1{{Iterator decremented ahead of its valid range}} } void behind_begin_decr(const std::vector &V) { @@ -166,13 +180,15 @@ } void incr_by_2_ahead_of_end(const std::vector &V) { - auto i = --V.end(); + auto i = --V.end(); // expected-note{{Iterator decremented by 1}} i += 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}} + // expected-note@-1{{Iterator incremented behind the past-the-end iterator}} } void incr_by_2_end(const std::vector &V) { auto i = V.end(); i += 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}} + // expected-note@-1{{Iterator incremented behind the past-the-end iterator}} } // Addition - operator+(int) @@ -199,13 +215,15 @@ } void incr_by_2_copy_ahead_of_end(const std::vector &V) { - auto i = --V.end(); + auto i = --V.end(); // expected-note{{Iterator decremented by 1}} auto j = i + 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}} + // expected-note@-1{{Iterator incremented behind the past-the-end iterator}} } void incr_by_2_copy_end(const std::vector &V) { auto i = V.end(); auto j = i + 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}} + // expected-note@-1{{Iterator incremented behind the past-the-end iterator}} } // Subtraction assignment - operator-=(int) @@ -213,11 +231,13 @@ void decr_by_2_begin(const std::vector &V) { auto i = V.begin(); i -= 2; // expected-warning{{Iterator decremented ahead of its valid range}} + // expected-note@-1{{Iterator decremented ahead of its valid range}} } void decr_by_2_behind_begin(const std::vector &V) { - auto i = ++V.begin(); + auto i = ++V.begin(); // expected-note{{Iterator incremented by 1}} i -= 2; // expected-warning{{Iterator decremented ahead of its valid range}} + // expected-note@-1{{Iterator decremented ahead of its valid range}} } void decr_by_2_behind_begin_by_2(const std::vector &V) { @@ -246,11 +266,13 @@ void decr_by_2_copy_begin(const std::vector &V) { auto i = V.begin(); auto j = i - 2; // expected-warning{{Iterator decremented ahead of its valid range}} + // expected-note@-1{{Iterator decremented ahead of its valid range}} } void decr_by_2_copy_behind_begin(const std::vector &V) { - auto i = ++V.begin(); + auto i = ++V.begin(); // expected-note{{Iterator incremented by 1}} auto j = i - 2; // expected-warning{{Iterator decremented ahead of its valid range}} + // expected-note@-1{{Iterator decremented ahead of its valid range}} } void decr_by_2_copy_behind_begin_by_2(const std::vector &V) { @@ -303,6 +325,7 @@ void subscript_zero_end(const std::vector &V) { auto i = V.end(); auto j = i[0]; // expected-warning{{Past-the-end iterator dereferenced}} + // expected-note@-1{{Past-the-end iterator dereferenced}} } // By negative number @@ -329,7 +352,8 @@ void subscript_negative_end(const std::vector &V) { auto i = V.end(); - auto j = i[-1]; // // expected-warning{{Past-the-end iterator dereferenced}} FIXME: expect no warning + auto j = i[-1]; // expected-warning{{Past-the-end iterator dereferenced}} FIXME: expect no warning + // expected-note@-1{{Past-the-end iterator dereferenced}} } // By positive number @@ -357,6 +381,7 @@ void subscript_positive_end(const std::vector &V) { auto i = V.end(); auto j = i[1]; // expected-warning{{Past-the-end iterator dereferenced}} FIXME: expect warning Iterator incremented behind the past-the-end iterator + // expected-note@-1{{Past-the-end iterator dereferenced}} FIXME: expect note@-1 Iterator incremented behind the past-the-end iterator } // @@ -388,6 +413,7 @@ void advance_plus_1_end(const std::vector &V) { auto i = V.end(); std::advance(i, 1); // expected-warning{{Iterator incremented behind the past-the-end iterator}} + // expected-note@-1{{Iterator incremented behind the past-the-end iterator}} } // std::advance() by -1 @@ -395,6 +421,7 @@ void advance_minus_1_begin(const std::vector &V) { auto i = V.begin(); std::advance(i, -1); // expected-warning{{Iterator decremented ahead of its valid range}} + // expected-note@-1{{Iterator decremented ahead of its valid range}} } void advance_minus_1_behind_begin(const std::vector &V) { @@ -435,13 +462,15 @@ } void advance_plus_2_ahead_of_end(const std::vector &V) { - auto i = --V.end(); + auto i = --V.end(); // expected-note{{Iterator decremented by 1}} std::advance(i, 2); // expected-warning{{Iterator incremented behind the past-the-end iterator}} + // expected-note@-1{{Iterator incremented behind the past-the-end iterator}} } void advance_plus_2_end(const std::vector &V) { auto i = V.end(); std::advance(i, 2); // expected-warning{{Iterator incremented behind the past-the-end iterator}} + // expected-note@-1{{Iterator incremented behind the past-the-end iterator}} } // std::advance() by -2 @@ -449,11 +478,13 @@ void advance_minus_2_begin(const std::vector &V) { auto i = V.begin(); std::advance(i, -2); // expected-warning{{Iterator decremented ahead of its valid range}} + // expected-note@-1{{Iterator decremented ahead of its valid range}} } void advance_minus_2_behind_begin(const std::vector &V) { - auto i = ++V.begin(); + auto i = ++V.begin(); // expected-note{{Iterator incremented by 1}} std::advance(i, -2); // expected-warning{{Iterator decremented ahead of its valid range}} + // expected-note@-1{{Iterator decremented ahead of its valid range}} } void advance_minus_2_unknown(const std::vector &V) { @@ -527,6 +558,7 @@ void next_plus_1_end(const std::vector &V) { auto i = V.end(); auto j = std::next(i); // expected-warning{{Iterator incremented behind the past-the-end iterator}} + // expected-note@-1{{Iterator incremented behind the past-the-end iterator}} } // std::next() by -1 @@ -534,6 +566,7 @@ void next_minus_1_begin(const std::vector &V) { auto i = V.begin(); auto j = std::next(i, -1); // expected-warning{{Iterator decremented ahead of its valid range}} + // expected-note@-1{{Iterator decremented ahead of its valid range}} } void next_minus_1_behind_begin(const std::vector &V) { @@ -574,13 +607,15 @@ } void next_plus_2_ahead_of_end(const std::vector &V) { - auto i = --V.end(); + auto i = --V.end(); // expected-note{{Iterator decremented by 1}} auto j = std::next(i, 2); // expected-warning{{Iterator incremented behind the past-the-end iterator}} + // expected-note@-1{{Iterator incremented behind the past-the-end iterator}} } void next_plus_2_end(const std::vector &V) { auto i = V.end(); auto j = std::next(i, 2); // expected-warning{{Iterator incremented behind the past-the-end iterator}} + // expected-note@-1{{Iterator incremented behind the past-the-end iterator}} } // std::next() by -2 @@ -588,11 +623,13 @@ void next_minus_2_begin(const std::vector &V) { auto i = V.begin(); auto j = std::next(i, -2); // expected-warning{{Iterator decremented ahead of its valid range}} + // expected-note@-1{{Iterator decremented ahead of its valid range}} } void next_minus_2_behind_begin(const std::vector &V) { - auto i = ++V.begin(); + auto i = ++V.begin(); // expected-note{{Iterator incremented by 1}} auto j = std::next(i, -2); // expected-warning{{Iterator decremented ahead of its valid range}} + // expected-note@-1{{Iterator decremented ahead of its valid range}} } void next_minus_2_unknown(const std::vector &V) { @@ -646,6 +683,7 @@ void prev_plus_1_begin(const std::vector &V) { auto i = V.begin(); auto j = std::prev(i); // expected-warning{{Iterator decremented ahead of its valid range}} + // expected-note@-1{{Iterator decremented ahead of its valid range}} } void prev_plus_1_behind_begin(const std::vector &V) { @@ -693,6 +731,7 @@ void prev_minus_1_end(const std::vector &V) { auto i = V.end(); auto j = std::prev(i, -1); // expected-warning{{Iterator incremented behind the past-the-end iterator}} + // expected-note@-1{{Iterator incremented behind the past-the-end iterator}} } // std::prev() by +2 @@ -700,11 +739,13 @@ void prev_plus_2_begin(const std::vector &V) { auto i = V.begin(); auto j = std::prev(i, 2); // expected-warning{{Iterator decremented ahead of its valid range}} + // expected-note@-1{{Iterator decremented ahead of its valid range}} } void prev_plus_2_behind_begin(const std::vector &V) { - auto i = ++V.begin(); + auto i = ++V.begin(); // expected-note{{Iterator incremented by 1}} auto j = std::prev(i, 2); // expected-warning{{Iterator decremented ahead of its valid range}} + // expected-note@-1{{Iterator decremented ahead of its valid range}} } void prev_plus_2_unknown(const std::vector &V) { @@ -740,13 +781,15 @@ } void prev_minus_2_ahead_of_end(const std::vector &V) { - auto i = --V.end(); + auto i = --V.end(); // expected-note{{Iterator decremented by 1}} auto j = std::prev(i, -2); // expected-warning{{Iterator incremented behind the past-the-end iterator}} + // expected-note@-1{{Iterator incremented behind the past-the-end iterator}} } void prev_minus_2_end(const std::vector &V) { auto i = V.end(); auto j = std::prev(i, -2); // expected-warning{{Iterator incremented behind the past-the-end iterator}} + // expected-note@-1{{Iterator incremented behind the past-the-end iterator}} } // std::prev() by 0 @@ -793,5 +836,15 @@ void arrow_deref_end(const std::vector &V) { auto i = V.end(); - int n = i->n; // expected-warning{{Past-the-end iterator dereferenced}} + int n = i->n; // expected-warning{{Past-the-end iterator dereferenced}} + // expected-note@-1{{Past-the-end iterator dereferenced}} +} + +// Path notes + +void deref_end2(const std::vector &V) { + auto i = --V.end(); // expected-note{{Iterator decremented by 1}} + ++i; // expected-note{{Iterator 'i' incremented by 1}} + *i; // expected-warning{{Past-the-end iterator dereferenced}} + // expected-note@-1{{Past-the-end iterator dereferenced}} }