Index: include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h =================================================================== --- include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h @@ -36,7 +36,7 @@ /// Construct a ConstraintVal indicating the constraint is underconstrained. ConditionTruthVal() {} - + /// Return true if the constraint is perfectly constrained to 'true'. bool isConstrainedTrue() const { return Val.hasValue() && Val.getValue(); @@ -58,11 +58,11 @@ return !Val.hasValue(); } }; - + class ConstraintManager { public: ConstraintManager() : NotifyAssumeClients(true) {} - + virtual ~ConstraintManager(); virtual ProgramStateRef assume(ProgramStateRef state, DefinedSVal Cond, @@ -99,25 +99,26 @@ return ProgramStatePair(StTrue, StFalse); } - virtual ProgramStateRef assumeWithinInclusiveRange(ProgramStateRef State, - NonLoc Value, - const llvm::APSInt &From, - const llvm::APSInt &To, - bool InBound) = 0; + virtual ProgramStateRef assumeInclusiveRange(ProgramStateRef State, + NonLoc Value, + const llvm::APSInt &From, + const llvm::APSInt &To, + bool InBound) = 0; - virtual ProgramStatePair assumeWithinInclusiveRangeDual( - ProgramStateRef State, NonLoc Value, const llvm::APSInt &From, - const llvm::APSInt &To) { - ProgramStateRef StInRange = assumeWithinInclusiveRange(State, Value, From, - To, true); + virtual ProgramStatePair assumeInclusiveRangeDual(ProgramStateRef State, + NonLoc Value, + const llvm::APSInt &From, + const llvm::APSInt &To) { + ProgramStateRef StInRange = + assumeInclusiveRange(State, Value, From, To, true); // If StTrue is infeasible, asserting the falseness of Cond is unnecessary // because the existing constraints already establish this. if (!StInRange) return ProgramStatePair((ProgramStateRef)nullptr, State); - ProgramStateRef StOutOfRange = assumeWithinInclusiveRange(State, Value, - From, To, false); + ProgramStateRef StOutOfRange = + assumeInclusiveRange(State, Value, From, To, false); if (!StOutOfRange) { // We are careful to return the original state, /not/ StTrue, // because we want to avoid having callers generate a new node @@ -147,7 +148,7 @@ const char *sep) = 0; virtual void EndPath(ProgramStateRef state) {} - + /// Convenience method to query the state to see if a symbol is null or /// not null, or if neither assumption can be made. ConditionTruthVal isNull(ProgramStateRef State, SymbolRef Sym) { @@ -173,7 +174,7 @@ virtual bool canReasonAbout(SVal X) const = 0; /// Returns whether or not a symbol is known to be null ("true"), known to be - /// non-null ("false"), or may be either ("underconstrained"). + /// non-null ("false"), or may be either ("underconstrained"). virtual ConditionTruthVal checkNull(ProgramStateRef State, SymbolRef Sym); }; Index: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h =================================================================== --- include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h @@ -98,18 +98,18 @@ /// This ctor is used when creating the first ProgramState object. ProgramState(ProgramStateManager *mgr, const Environment& env, StoreRef st, GenericDataMap gdm); - + /// Copy ctor - We must explicitly define this or else the "Next" ptr /// in FoldingSetNode will also get copied. ProgramState(const ProgramState &RHS); - + ~ProgramState(); /// Return the ProgramStateManager associated with this state. ProgramStateManager &getStateManager() const { return *stateMgr; } - + /// Return the ConstraintManager. ConstraintManager &getConstraintManager() const; @@ -121,7 +121,7 @@ /// is a mapping from locations to values. Store getStore() const { return store; } - + /// getGDM - Return the generic data map associated with this state. GenericDataMap getGDM() const { return GDM; } @@ -197,10 +197,10 @@ /// /// This returns a new state with the added constraint on \p cond. /// If no new state is feasible, NULL is returned. - ProgramStateRef assumeWithinInclusiveRange(DefinedOrUnknownSVal Val, - const llvm::APSInt &From, - const llvm::APSInt &To, - bool assumption) const; + ProgramStateRef assumeInclusiveRange(DefinedOrUnknownSVal Val, + const llvm::APSInt &From, + const llvm::APSInt &To, + bool assumption) const; /// Assumes given range both "true" and "false" for \p Val, and returns both /// corresponding states (respectively). @@ -208,14 +208,13 @@ /// This is more efficient than calling assume() twice. Note that one (but not /// both) of the returned states may be NULL. std::pair - assumeWithinInclusiveRange(DefinedOrUnknownSVal Val, const llvm::APSInt &From, - const llvm::APSInt &To) const; + assumeInclusiveRange(DefinedOrUnknownSVal Val, const llvm::APSInt &From, + const llvm::APSInt &To) const; - /// \brief Check if the given SVal is constrained to zero or is a zero /// constant. ConditionTruthVal isNull(SVal V) const; - + /// Utility method for getting regions. const VarRegion* getRegion(const VarDecl *D, const LocationContext *LC) const; @@ -254,7 +253,7 @@ /// \param IS the set of invalidated symbols. /// \param Call if non-null, the invalidated regions represent parameters to /// the call and should be considered directly invalidated. - /// \param ITraits information about special handling for a particular + /// \param ITraits information about special handling for a particular /// region/symbol. ProgramStateRef invalidateRegions(ArrayRef Regions, const Expr *E, @@ -278,7 +277,7 @@ /// Get the lvalue for a variable reference. Loc getLValue(const VarDecl *D, const LocationContext *LC) const; - Loc getLValue(const CompoundLiteralExpr *literal, + Loc getLValue(const CompoundLiteralExpr *literal, const LocationContext *LC) const; /// Get the lvalue for an ivar reference. @@ -295,7 +294,7 @@ /// Returns the SVal bound to the statement 'S' in the state's environment. SVal getSVal(const Stmt *S, const LocationContext *LCtx) const; - + SVal getSValAsScalarOrLoc(const Stmt *Ex, const LocationContext *LCtx) const; /// \brief Return the value bound to the specified location. @@ -310,7 +309,7 @@ SVal getSVal(const MemRegion* R) const; SVal getSValAsScalarOrLoc(const MemRegion *R) const; - + /// \brief Visits the symbols reachable from the given SVal using the provided /// SymbolVisitor. /// @@ -319,22 +318,22 @@ /// visitor to avoid repeated initialization cost. /// \sa ScanReachableSymbols bool scanReachableSymbols(SVal val, SymbolVisitor& visitor) const; - + /// \brief Visits the symbols reachable from the SVals in the given range /// using the provided SymbolVisitor. bool scanReachableSymbols(const SVal *I, const SVal *E, SymbolVisitor &visitor) const; - + /// \brief Visits the symbols reachable from the regions in the given /// MemRegions range using the provided SymbolVisitor. - bool scanReachableSymbols(const MemRegion * const *I, + bool scanReachableSymbols(const MemRegion * const *I, const MemRegion * const *E, SymbolVisitor &visitor) const; template CB scanReachableSymbols(SVal val) const; template CB scanReachableSymbols(const SVal *beg, const SVal *end) const; - + template CB scanReachableSymbols(const MemRegion * const *beg, const MemRegion * const *end) const; @@ -469,7 +468,7 @@ /// A BumpPtrAllocator to allocate states. llvm::BumpPtrAllocator &Alloc; - + /// A vector of ProgramStates that we can reuse. std::vector freeStates; @@ -632,9 +631,9 @@ inline ConstraintManager &ProgramState::getConstraintManager() const { return stateMgr->getConstraintManager(); } - + inline const VarRegion* ProgramState::getRegion(const VarDecl *D, - const LocationContext *LC) const + const LocationContext *LC) const { return getStateManager().getRegionManager().getVarRegion(D, LC); } @@ -647,7 +646,7 @@ return getStateManager().ConstraintMgr ->assume(this, Cond.castAs(), Assumption); } - + inline std::pair ProgramState::assume(DefinedOrUnknownSVal Cond) const { if (Cond.isUnknown()) @@ -657,31 +656,29 @@ ->assumeDual(this, Cond.castAs()); } -inline ProgramStateRef -ProgramState::assumeWithinInclusiveRange(DefinedOrUnknownSVal Val, - const llvm::APSInt &From, - const llvm::APSInt &To, - bool Assumption) const { +inline ProgramStateRef ProgramState::assumeInclusiveRange( + DefinedOrUnknownSVal Val, const llvm::APSInt &From, const llvm::APSInt &To, + bool Assumption) const { if (Val.isUnknown()) return this; assert(Val.getAs() && "Only NonLocs are supported!"); - return getStateManager().ConstraintMgr->assumeWithinInclusiveRange( - this, Val.castAs(), From, To, Assumption); + return getStateManager().ConstraintMgr->assumeInclusiveRange( + this, Val.castAs(), From, To, Assumption); } inline std::pair -ProgramState::assumeWithinInclusiveRange(DefinedOrUnknownSVal Val, - const llvm::APSInt &From, - const llvm::APSInt &To) const { +ProgramState::assumeInclusiveRange(DefinedOrUnknownSVal Val, + const llvm::APSInt &From, + const llvm::APSInt &To) const { if (Val.isUnknown()) return std::make_pair(this, this); assert(Val.getAs() && "Only NonLocs are supported!"); - return getStateManager().ConstraintMgr - ->assumeWithinInclusiveRangeDual(this, Val.castAs(), From, To); + return getStateManager().ConstraintMgr->assumeInclusiveRangeDual( + this, Val.castAs(), From, To); } inline ProgramStateRef ProgramState::bindLoc(SVal LV, SVal V) const { @@ -810,7 +807,7 @@ scanReachableSymbols(val, cb); return cb; } - + template CB ProgramState::scanReachableSymbols(const SVal *beg, const SVal *end) const { CB cb(this); Index: lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp +++ lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp @@ -254,7 +254,7 @@ const llvm::APSInt &Min = BVF.getValue(R[I].first, T); const llvm::APSInt &Max = BVF.getValue(R[I].second, T); assert(Min <= Max); - State = CM.assumeWithinInclusiveRange(State, *N, Min, Max, false); + State = CM.assumeInclusiveRange(State, *N, Min, Max, false); if (!State) break; } @@ -288,7 +288,7 @@ const llvm::APSInt &Left = BVF.getValue(R[0].first - 1ULL, T); if (Left != PlusInf) { assert(MinusInf <= Left); - State = CM.assumeWithinInclusiveRange(State, *N, MinusInf, Left, false); + State = CM.assumeInclusiveRange(State, *N, MinusInf, Left, false); if (!State) return nullptr; } @@ -296,7 +296,7 @@ const llvm::APSInt &Right = BVF.getValue(R[E - 1].second + 1ULL, T); if (Right != MinusInf) { assert(Right <= PlusInf); - State = CM.assumeWithinInclusiveRange(State, *N, Right, PlusInf, false); + State = CM.assumeInclusiveRange(State, *N, Right, PlusInf, false); if (!State) return nullptr; } @@ -305,7 +305,7 @@ const llvm::APSInt &Min = BVF.getValue(R[I - 1].second + 1ULL, T); const llvm::APSInt &Max = BVF.getValue(R[I].first - 1ULL, T); assert(Min <= Max); - State = CM.assumeWithinInclusiveRange(State, *N, Min, Max, false); + State = CM.assumeInclusiveRange(State, *N, Min, Max, false); if (!State) return nullptr; } Index: lib/StaticAnalyzer/Core/ExprEngine.cpp =================================================================== --- lib/StaticAnalyzer/Core/ExprEngine.cpp +++ lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -1836,7 +1836,7 @@ ProgramStateRef StateCase; if (Optional NL = CondV.getAs()) std::tie(StateCase, DefaultSt) = - DefaultSt->assumeWithinInclusiveRange(*NL, V1, V2); + DefaultSt->assumeInclusiveRange(*NL, V1, V2); else // UnknownVal StateCase = DefaultSt; Index: lib/StaticAnalyzer/Core/SimpleConstraintManager.h =================================================================== --- lib/StaticAnalyzer/Core/SimpleConstraintManager.h +++ lib/StaticAnalyzer/Core/SimpleConstraintManager.h @@ -38,7 +38,7 @@ ProgramStateRef assume(ProgramStateRef state, NonLoc Cond, bool Assumption); - ProgramStateRef assumeWithinInclusiveRange(ProgramStateRef State, + ProgramStateRef assumeInclusiveRange(ProgramStateRef State, NonLoc Value, const llvm::APSInt &From, const llvm::APSInt &To, Index: lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp =================================================================== --- lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp +++ lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp @@ -190,7 +190,7 @@ } // end switch } -ProgramStateRef SimpleConstraintManager::assumeWithinInclusiveRange( +ProgramStateRef SimpleConstraintManager::assumeInclusiveRange( ProgramStateRef State, NonLoc Value, const llvm::APSInt &From, const llvm::APSInt &To, bool InRange) { @@ -207,7 +207,7 @@ switch (Value.getSubKind()) { default: - llvm_unreachable("'assumeWithinInclusiveRange' is not implemented" + llvm_unreachable("'assumeInclusiveRange' is not implemented" "for this NonLoc"); case nonloc::LocAsIntegerKind: