blob: 6848ced2be70f03ece8b96669d294d5649b59032 [file] [log] [blame]
Ted Kremenekd59cccc2008-02-14 18:28:23 +00001// 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 Greif843e9342008-03-06 10:40:09 +000010// This file defines GRSimpleVals, a sub-class of GRTransferFuncs that
Ted Kremenekd59cccc2008-02-14 18:28:23 +000011// 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 Kremeneke01c9872008-02-14 22:36:46 +000020#include "clang/Analysis/PathSensitive/GRExprEngine.h"
Ted Kremenekd59cccc2008-02-14 18:28:23 +000021
22namespace clang {
23
Ted Kremenekf1ae7052008-04-03 17:57:38 +000024class PathDiagnostic;
25class ASTContext;
26
Ted Kremenekd59cccc2008-02-14 18:28:23 +000027class GRSimpleVals : public GRTransferFuncs {
Ted Kremenekad8329e2008-07-18 15:27:58 +000028protected:
29
Ted Kremeneke04a5cb2008-11-15 00:20:05 +000030 virtual SVal DetermEvalBinOpNN(GRExprEngine& Eng,
Ted Kremenekad8329e2008-07-18 15:27:58 +000031 BinaryOperator::Opcode Op,
Zhongxing Xu1c96b242008-10-17 05:57:07 +000032 NonLoc L, NonLoc R);
Ted Kremenekad8329e2008-07-18 15:27:58 +000033
Ted Kremenekd59cccc2008-02-14 18:28:23 +000034public:
35 GRSimpleVals() {}
36 virtual ~GRSimpleVals() {}
37
Ted Kremenekc3f261d2008-02-14 18:40:24 +000038 // Casts.
39
Zhongxing Xu1c96b242008-10-17 05:57:07 +000040 virtual SVal EvalCast(GRExprEngine& Engine, NonLoc V, QualType CastT);
41 virtual SVal EvalCast(GRExprEngine& Engine, Loc V, QualType CastT);
Ted Kremenekc3f261d2008-02-14 18:40:24 +000042
43 // Unary Operators.
44
Zhongxing Xu1c96b242008-10-17 05:57:07 +000045 virtual SVal EvalMinus(GRExprEngine& Engine, UnaryOperator* U, NonLoc X);
Ted Kremenekaa1c4e52008-02-21 18:02:17 +000046
Zhongxing Xu1c96b242008-10-17 05:57:07 +000047 virtual SVal EvalComplement(GRExprEngine& Engine, NonLoc X);
Ted Kremenek6cb0b542008-02-14 19:37:24 +000048
49 // Binary Operators.
50
Zhongxing Xu1c96b242008-10-17 05:57:07 +000051 virtual SVal EvalBinOp(GRExprEngine& Engine, BinaryOperator::Opcode Op,
52 Loc L, Loc R);
Ted Kremenekc6fbdcd2008-02-15 23:15:23 +000053
Ted Kremenekb640b3b2008-02-15 00:52:26 +000054 // Pointer arithmetic.
55
Zhongxing Xu1c96b242008-10-17 05:57:07 +000056 virtual SVal EvalBinOp(GRExprEngine& Engine, BinaryOperator::Opcode Op,
57 Loc L, NonLoc R);
Ted Kremenekb640b3b2008-02-15 00:52:26 +000058
Ted Kremenek06747692008-02-26 23:04:29 +000059 // Calls.
60
Ted Kremenek4adc81e2008-08-13 04:27:00 +000061 virtual void EvalCall(ExplodedNodeSet<GRState>& Dst,
Ted Kremenek00a3a5f2008-03-12 01:21:45 +000062 GRExprEngine& Engine,
Ted Kremenek4adc81e2008-08-13 04:27:00 +000063 GRStmtNodeBuilder<GRState>& Builder,
Zhongxing Xu1c96b242008-10-17 05:57:07 +000064 CallExpr* CE, SVal L,
Ted Kremenek4adc81e2008-08-13 04:27:00 +000065 ExplodedNode<GRState>* Pred);
Ted Kremenek06747692008-02-26 23:04:29 +000066
Ted Kremenek4adc81e2008-08-13 04:27:00 +000067 virtual void EvalObjCMessageExpr(ExplodedNodeSet<GRState>& Dst,
Ted Kremeneke695e1c2008-04-15 23:06:53 +000068 GRExprEngine& Engine,
Ted Kremenek4adc81e2008-08-13 04:27:00 +000069 GRStmtNodeBuilder<GRState>& Builder,
Ted Kremeneke695e1c2008-04-15 23:06:53 +000070 ObjCMessageExpr* ME,
Ted Kremenek4adc81e2008-08-13 04:27:00 +000071 ExplodedNode<GRState>* Pred);
Ted Kremeneke695e1c2008-04-15 23:06:53 +000072
73
74
Ted Kremenekf1ae7052008-04-03 17:57:38 +000075 static void GeneratePathDiagnostic(PathDiagnostic& PD, ASTContext& Ctx,
Ted Kremenek4adc81e2008-08-13 04:27:00 +000076 ExplodedNode<GRState>* N);
Ted Kremenekf1ae7052008-04-03 17:57:38 +000077
Ted Kremenekc6fbdcd2008-02-15 23:15:23 +000078protected:
Ted Kremenekd59cccc2008-02-14 18:28:23 +000079
Zhongxing Xu1c96b242008-10-17 05:57:07 +000080 // Equality operators for Locs.
Ted Kremenekaa1c4e52008-02-21 18:02:17 +000081
Zhongxing Xu1c96b242008-10-17 05:57:07 +000082 SVal EvalEQ(GRExprEngine& Engine, Loc L, Loc R);
83 SVal EvalNE(GRExprEngine& Engine, Loc L, Loc R);
Ted Kremenekaa1c4e52008-02-21 18:02:17 +000084};
Ted Kremenekd59cccc2008-02-14 18:28:23 +000085
86} // end clang namespace
87
88#endif