diff options
Diffstat (limited to 'clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h')
-rw-r--r-- | clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h index 61dfdbb0688b..1df47dae25bf 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h @@ -96,6 +96,17 @@ protected: QualType OriginalTy); SVal evalCastSubKind(nonloc::PointerToMember V, QualType CastTy, QualType OriginalTy); + /// Reduce cast expression by removing redundant intermediate casts. + /// E.g. + /// - (char)(short)(int x) -> (char)(int x) + /// - (int)(int x) -> int x + /// + /// \param V -- SymbolVal, which pressumably contains SymbolCast or any symbol + /// that is applicable for cast operation. + /// \param CastTy -- QualType, which `V` shall be cast to. + /// \return SVal with simplified cast expression. + /// \note: Currently only support integral casts. + SVal simplifySymbolCast(nonloc::SymbolVal V, QualType CastTy); public: SValBuilder(llvm::BumpPtrAllocator &alloc, ASTContext &context, @@ -103,18 +114,6 @@ public: virtual ~SValBuilder() = default; - bool haveSameType(const SymExpr *Sym1, const SymExpr *Sym2) { - return haveSameType(Sym1->getType(), Sym2->getType()); - } - - bool haveSameType(QualType Ty1, QualType Ty2) { - // FIXME: Remove the second disjunct when we support symbolic - // truncation/extension. - return (Context.getCanonicalType(Ty1) == Context.getCanonicalType(Ty2) || - (Ty1->isIntegralOrEnumerationType() && - Ty2->isIntegralOrEnumerationType())); - } - SVal evalCast(SVal V, QualType CastTy, QualType OriginalTy); // Handles casts of type CK_IntegralCast. |