Ted Kremenek | d59cccc | 2008-02-14 18:28:23 +0000 | [diff] [blame] | 1 | // GRSimpleVals.h - Transfer functions for tracking simple values -*- C++ -*--// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Gabor Greif | 843e934 | 2008-03-06 10:40:09 +0000 | [diff] [blame] | 10 | // This file defines GRSimpleVals, a sub-class of GRTransferFuncs that |
Ted Kremenek | d59cccc | 2008-02-14 18:28:23 +0000 | [diff] [blame] | 11 | // provides transfer functions for performing simple value tracking with |
| 12 | // limited support for symbolics. |
| 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
| 16 | #ifndef LLVM_CLANG_ANALYSIS_GRSIMPLEVALS |
| 17 | #define LLVM_CLANG_ANALYSIS_GRSIMPLEVALS |
| 18 | |
| 19 | #include "clang/Analysis/PathSensitive/GRTransferFuncs.h" |
Ted Kremenek | e01c987 | 2008-02-14 22:36:46 +0000 | [diff] [blame] | 20 | #include "clang/Analysis/PathSensitive/GRExprEngine.h" |
Ted Kremenek | d59cccc | 2008-02-14 18:28:23 +0000 | [diff] [blame] | 21 | |
| 22 | namespace clang { |
| 23 | |
Ted Kremenek | f1ae705 | 2008-04-03 17:57:38 +0000 | [diff] [blame] | 24 | class PathDiagnostic; |
| 25 | class ASTContext; |
| 26 | |
Ted Kremenek | d59cccc | 2008-02-14 18:28:23 +0000 | [diff] [blame] | 27 | class GRSimpleVals : public GRTransferFuncs { |
| 28 | public: |
| 29 | GRSimpleVals() {} |
| 30 | virtual ~GRSimpleVals() {} |
| 31 | |
Ted Kremenek | 50a6d0c | 2008-04-09 21:41:14 +0000 | [diff] [blame^] | 32 | virtual void RegisterChecks(GRExprEngine& Eng); |
| 33 | |
Ted Kremenek | c3f261d | 2008-02-14 18:40:24 +0000 | [diff] [blame] | 34 | // Casts. |
| 35 | |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 36 | virtual RVal EvalCast(GRExprEngine& Engine, NonLVal V, QualType CastT); |
| 37 | virtual RVal EvalCast(GRExprEngine& Engine, LVal V, QualType CastT); |
Ted Kremenek | c3f261d | 2008-02-14 18:40:24 +0000 | [diff] [blame] | 38 | |
| 39 | // Unary Operators. |
| 40 | |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 41 | virtual RVal EvalMinus(GRExprEngine& Engine, UnaryOperator* U, NonLVal X); |
Ted Kremenek | aa1c4e5 | 2008-02-21 18:02:17 +0000 | [diff] [blame] | 42 | |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 43 | virtual RVal EvalComplement(GRExprEngine& Engine, NonLVal X); |
Ted Kremenek | 6cb0b54 | 2008-02-14 19:37:24 +0000 | [diff] [blame] | 44 | |
| 45 | // Binary Operators. |
| 46 | |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 47 | virtual RVal EvalBinOp(GRExprEngine& Engine, BinaryOperator::Opcode Op, |
Ted Kremenek | aa1c4e5 | 2008-02-21 18:02:17 +0000 | [diff] [blame] | 48 | NonLVal L, NonLVal R); |
Ted Kremenek | 6cb0b54 | 2008-02-14 19:37:24 +0000 | [diff] [blame] | 49 | |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 50 | virtual RVal EvalBinOp(GRExprEngine& Engine, BinaryOperator::Opcode Op, |
Ted Kremenek | aa1c4e5 | 2008-02-21 18:02:17 +0000 | [diff] [blame] | 51 | LVal L, LVal R); |
Ted Kremenek | c6fbdcd | 2008-02-15 23:15:23 +0000 | [diff] [blame] | 52 | |
Ted Kremenek | b640b3b | 2008-02-15 00:52:26 +0000 | [diff] [blame] | 53 | // Pointer arithmetic. |
| 54 | |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 55 | virtual RVal EvalBinOp(GRExprEngine& Engine, BinaryOperator::Opcode Op, |
Ted Kremenek | aa1c4e5 | 2008-02-21 18:02:17 +0000 | [diff] [blame] | 56 | LVal L, NonLVal R); |
Ted Kremenek | b640b3b | 2008-02-15 00:52:26 +0000 | [diff] [blame] | 57 | |
Ted Kremenek | 0674769 | 2008-02-26 23:04:29 +0000 | [diff] [blame] | 58 | // Calls. |
| 59 | |
Ted Kremenek | 330dddd | 2008-03-05 00:33:14 +0000 | [diff] [blame] | 60 | virtual void EvalCall(ExplodedNodeSet<ValueState>& Dst, |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 61 | GRExprEngine& Engine, |
Ted Kremenek | 330dddd | 2008-03-05 00:33:14 +0000 | [diff] [blame] | 62 | GRStmtNodeBuilder<ValueState>& Builder, |
Ted Kremenek | 330dddd | 2008-03-05 00:33:14 +0000 | [diff] [blame] | 63 | CallExpr* CE, LVal L, |
| 64 | ExplodedNode<ValueState>* Pred); |
Ted Kremenek | 0674769 | 2008-02-26 23:04:29 +0000 | [diff] [blame] | 65 | |
Ted Kremenek | f1ae705 | 2008-04-03 17:57:38 +0000 | [diff] [blame] | 66 | static void GeneratePathDiagnostic(PathDiagnostic& PD, ASTContext& Ctx, |
| 67 | ExplodedNode<ValueState>* N); |
| 68 | |
Ted Kremenek | c6fbdcd | 2008-02-15 23:15:23 +0000 | [diff] [blame] | 69 | protected: |
Ted Kremenek | d59cccc | 2008-02-14 18:28:23 +0000 | [diff] [blame] | 70 | |
Ted Kremenek | aa1c4e5 | 2008-02-21 18:02:17 +0000 | [diff] [blame] | 71 | // Equality operators for LVals. |
| 72 | |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 73 | RVal EvalEQ(GRExprEngine& Engine, LVal L, LVal R); |
| 74 | RVal EvalNE(GRExprEngine& Engine, LVal L, LVal R); |
Ted Kremenek | aa1c4e5 | 2008-02-21 18:02:17 +0000 | [diff] [blame] | 75 | }; |
Ted Kremenek | d59cccc | 2008-02-14 18:28:23 +0000 | [diff] [blame] | 76 | |
| 77 | } // end clang namespace |
| 78 | |
| 79 | #endif |