Cppcheck
infer.h
Go to the documentation of this file.
1 /*
2  * Cppcheck - A tool for static C/C++ code analysis
3  * Copyright (C) 2007-2023 Cppcheck team.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef inferH
20 #define inferH
21 
22 #include "config.h"
23 #include "mathlib.h"
24 #include "vfvalue.h"
25 
26 #include <list>
27 #include <string>
28 #include <vector>
29 
30 template<class T> class ValuePtr;
31 
32 struct InferModel {
33  virtual bool match(const ValueFlow::Value& value) const = 0;
34  virtual ValueFlow::Value yield(MathLib::bigint value) const = 0;
35  virtual ~InferModel() = default;
36  InferModel(const InferModel&) = default;
37 protected:
38  InferModel() = default;
39 };
40 
41 std::vector<ValueFlow::Value> infer(const ValuePtr<InferModel>& model,
42  const std::string& op,
43  std::list<ValueFlow::Value> lhsValues,
44  std::list<ValueFlow::Value> rhsValues);
45 
46 std::vector<ValueFlow::Value> infer(const ValuePtr<InferModel>& model,
47  const std::string& op,
48  MathLib::bigint lhs,
49  std::list<ValueFlow::Value> rhsValues);
50 
51 std::vector<ValueFlow::Value> infer(const ValuePtr<InferModel>& model,
52  const std::string& op,
53  std::list<ValueFlow::Value> lhsValues,
54  MathLib::bigint rhs);
55 
56 CPPCHECKLIB std::vector<MathLib::bigint> getMinValue(const ValuePtr<InferModel>& model, const std::list<ValueFlow::Value>& values);
57 std::vector<MathLib::bigint> getMaxValue(const ValuePtr<InferModel>& model, const std::list<ValueFlow::Value>& values);
58 
59 #endif
long long bigint
Definition: mathlib.h:68
#define CPPCHECKLIB
Definition: config.h:35
std::vector< MathLib::bigint > getMaxValue(const ValuePtr< InferModel > &model, const std::list< ValueFlow::Value > &values)
Definition: infer.cpp:383
CPPCHECKLIB std::vector< MathLib::bigint > getMinValue(const ValuePtr< InferModel > &model, const std::list< ValueFlow::Value > &values)
Definition: infer.cpp:377
std::vector< ValueFlow::Value > infer(const ValuePtr< InferModel > &model, const std::string &op, std::list< ValueFlow::Value > lhsValues, std::list< ValueFlow::Value > rhsValues)
Definition: infer.cpp:286
virtual bool match(const ValueFlow::Value &value) const =0
virtual ValueFlow::Value yield(MathLib::bigint value) const =0
InferModel()=default
InferModel(const InferModel &)=default
virtual ~InferModel()=default