diff options
| author | Jordan Rose <jordan_rose@apple.com> | 2012-08-23 23:01:39 +0000 |
|---|---|---|
| committer | Jordan Rose <jordan_rose@apple.com> | 2012-08-23 23:01:39 +0000 |
| commit | 081af085eb6ea6b2c6a0b7fdf7cbc04448a2ad8a (patch) | |
| tree | 0c451adf279ec25da9221bf7ee5a6258525aebbd /clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp | |
| parent | acb7115bdea96ac79583aeb3684aa1c06dc627dd (diff) | |
| download | bcm5719-llvm-081af085eb6ea6b2c6a0b7fdf7cbc04448a2ad8a.tar.gz bcm5719-llvm-081af085eb6ea6b2c6a0b7fdf7cbc04448a2ad8a.zip | |
[analyzer] Handle UserDefinedConversion casts in C++.
This is trivial; the UserDefinedConversion always wraps a CXXMemberCallExpr
for the appropriate conversion function, so it's just a matter of
propagating that value to the CastExpr itself.
llvm-svn: 162494
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp')
| -rw-r--r-- | clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp index 935d7aea0ca..f65a6ebc346 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp @@ -242,7 +242,9 @@ void ExprEngine::VisitCast(const CastExpr *CastE, const Expr *Ex, I != E; ++I) { Pred = *I; - + ProgramStateRef state = Pred->getState(); + const LocationContext *LCtx = Pred->getLocationContext(); + switch (CastE->getCastKind()) { case CK_LValueToRValue: llvm_unreachable("LValueToRValue casts handled earlier."); @@ -262,6 +264,7 @@ void ExprEngine::VisitCast(const CastExpr *CastE, const Expr *Ex, case CK_NonAtomicToAtomic: // True no-ops. case CK_NoOp: + case CK_UserDefinedConversion: case CK_FunctionToPointerDecay: { // Copy the SVal of Ex to CastE. ProgramStateRef state = Pred->getState(); @@ -299,8 +302,6 @@ void ExprEngine::VisitCast(const CastExpr *CastE, const Expr *Ex, case CK_AnyPointerToBlockPointerCast: case CK_ObjCObjectLValueCast: { // Delegate to SValBuilder to process. - ProgramStateRef state = Pred->getState(); - const LocationContext *LCtx = Pred->getLocationContext(); SVal V = state->getSVal(Ex, LCtx); V = svalBuilder.evalCast(V, T, ExTy); state = state->BindExpr(CastE, LCtx, V); @@ -310,8 +311,6 @@ void ExprEngine::VisitCast(const CastExpr *CastE, const Expr *Ex, case CK_DerivedToBase: case CK_UncheckedDerivedToBase: { // For DerivedToBase cast, delegate to the store manager. - ProgramStateRef state = Pred->getState(); - const LocationContext *LCtx = Pred->getLocationContext(); SVal val = state->getSVal(Ex, LCtx); val = getStoreManager().evalDerivedToBase(val, CastE); state = state->BindExpr(CastE, LCtx, val); @@ -320,8 +319,6 @@ void ExprEngine::VisitCast(const CastExpr *CastE, const Expr *Ex, } // Handle C++ dyn_cast. case CK_Dynamic: { - ProgramStateRef state = Pred->getState(); - const LocationContext *LCtx = Pred->getLocationContext(); SVal val = state->getSVal(Ex, LCtx); // Compute the type of the result. @@ -369,7 +366,6 @@ void ExprEngine::VisitCast(const CastExpr *CastE, const Expr *Ex, case CK_BaseToDerivedMemberPointer: case CK_DerivedToBaseMemberPointer: case CK_ReinterpretMemberPointer: - case CK_UserDefinedConversion: case CK_ConstructorConversion: case CK_VectorSplat: case CK_MemberPointerToBoolean: @@ -378,12 +374,10 @@ void ExprEngine::VisitCast(const CastExpr *CastE, const Expr *Ex, QualType resultType = CastE->getType(); if (CastE->isGLValue()) resultType = getContext().getPointerType(resultType); - const LocationContext *LCtx = Pred->getLocationContext(); SVal result = svalBuilder.conjureSymbolVal(0, CastE, LCtx, resultType, currBldrCtx->blockCount()); - ProgramStateRef state = Pred->getState()->BindExpr(CastE, LCtx, - result); + state = state->BindExpr(CastE, LCtx, result); Bldr.generateNode(CastE, Pred, state); continue; } |

