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