diff options
-rw-r--r-- | include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h | 10 | ||||
-rw-r--r-- | lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp | 6 | ||||
-rw-r--r-- | lib/StaticAnalyzer/Core/ProgramState.cpp | 4 |
3 files changed, 9 insertions, 11 deletions
diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h b/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h index 84a839819c..3785e900c8 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h @@ -334,14 +334,14 @@ public: /// \brief Get dynamic type information for a region. DynamicTypeInfo getDynamicTypeInfo(const MemRegion *Reg) const; - /// \brief Add dynamic type information to the region; return the new state. - ProgramStateRef addDynamicTypeInfo(const MemRegion *Reg, + /// \brief Set dynamic type information of the region; return the new state. + ProgramStateRef setDynamicTypeInfo(const MemRegion *Reg, DynamicTypeInfo NewTy) const; - /// \brief Add dynamic type information to the region; return the new state. - ProgramStateRef addDynamicTypeInfo(const MemRegion *Reg, + /// \brief Set dynamic type information of the region; return the new state. + ProgramStateRef setDynamicTypeInfo(const MemRegion *Reg, QualType NewTy) const { - return addDynamicTypeInfo(Reg, DynamicTypeInfo(NewTy)); + return setDynamicTypeInfo(Reg, DynamicTypeInfo(NewTy)); } //==---------------------------------------------------------------------==// diff --git a/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp b/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp index d9edab8ede..d8bb5ea7a5 100644 --- a/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp +++ b/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp @@ -68,7 +68,7 @@ void DynamicTypePropagation::checkPostCall(const CallEvent &Call, return; QualType DynResTy = C.getASTContext().getObjCObjectPointerType(QualType(ObjTy, 0)); - C.addTransition(State->addDynamicTypeInfo(RetReg, DynResTy)); + C.addTransition(State->setDynamicTypeInfo(RetReg, DynResTy)); break; } case OMF_init: { @@ -78,7 +78,7 @@ void DynamicTypePropagation::checkPostCall(const CallEvent &Call, if (!RecReg) return; DynamicTypeInfo RecDynType = State->getDynamicTypeInfo(RecReg); - C.addTransition(State->addDynamicTypeInfo(RetReg, RecDynType)); + C.addTransition(State->setDynamicTypeInfo(RetReg, RecDynType)); break; } } @@ -98,7 +98,7 @@ void DynamicTypePropagation::checkPostStmt(const ImplicitCastExpr *CastE, case CK_BitCast: // Only handle ObjCObjects for now. if (const Type *NewTy = getBetterObjCType(CastE, C)) - C.addTransition(C.getState()->addDynamicTypeInfo(ToR, QualType(NewTy,0))); + C.addTransition(C.getState()->setDynamicTypeInfo(ToR, QualType(NewTy,0))); break; } return; diff --git a/lib/StaticAnalyzer/Core/ProgramState.cpp b/lib/StaticAnalyzer/Core/ProgramState.cpp index c20979bddb..0e5ff785bf 100644 --- a/lib/StaticAnalyzer/Core/ProgramState.cpp +++ b/lib/StaticAnalyzer/Core/ProgramState.cpp @@ -762,12 +762,10 @@ DynamicTypeInfo ProgramState::getDynamicTypeInfo(const MemRegion *Reg) const { return DynamicTypeInfo(); } -ProgramStateRef ProgramState::addDynamicTypeInfo(const MemRegion *Reg, +ProgramStateRef ProgramState::setDynamicTypeInfo(const MemRegion *Reg, DynamicTypeInfo NewTy) const { if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(Reg)) { SymbolRef Sym = SR->getSymbol(); - // TODO: Instead of resetting the type info, check the old type info and - // merge and pick the most precise type. ProgramStateRef NewState = set<DynamicTypeMap>(Sym, NewTy); assert(NewState); return NewState; |