Static Value-Flow Analysis
Loading...
Searching...
No Matches
SVFType.cpp
Go to the documentation of this file.
1#include "SVFIR/SVFType.h"
2#include <sstream>
3
4namespace SVF
5{
6
7SVFType* SVFType::svfI8Ty = nullptr;
8SVFType* SVFType::svfPtrTy = nullptr;
9
10std::string SVFType::toString() const
11{
12 std::ostringstream os;
13 print(os);
14 return os.str();
15}
16
17std::ostream& operator<<(std::ostream& os, const SVFType& type)
18{
19 type.print(os);
20 return os;
21}
22
23void SVFPointerType::print(std::ostream& os) const
24{
25 os << "ptr";
26}
27
28void SVFIntegerType::print(std::ostream& os) const
29{
30 if (signAndWidth < 0)
31 os << 'i' << -signAndWidth;
32 else
33 os << 'u' << signAndWidth;
34}
35
36void SVFFunctionType::print(std::ostream& os) const
37{
38 os << *getReturnType() << "(";
39
40 // Print parameters
41 for (size_t i = 0; i < params.size(); ++i)
42 {
43 os << *params[i];
44 // Add comma after all params except the last one
45 if (i != params.size() - 1)
46 {
47 os << ", ";
48 }
49 }
50
51 // Add varargs indicator if needed
52 if (isVarArg())
53 {
54 if (!params.empty())
55 {
56 os << ", ";
57 }
58 os << "...";
59 }
60
61 os << ")";
62}
63
64void SVFStructType::print(std::ostream& os) const
65{
66 os << "S." << name << " {";
67
68 // Print fields
69 for (size_t i = 0; i < fields.size(); ++i)
70 {
71 os << *fields[i];
72 // Add comma after all fields except the last one
73 if (i != fields.size() - 1)
74 {
75 os << ", ";
76 }
77 }
78 os << "}";
79}
80
81void SVFArrayType::print(std::ostream& os) const
82{
83 os << '[' << numOfElement << 'x' << *typeOfElement << ']';
84}
85
86void SVFOtherType::print(std::ostream& os) const
87{
88 os << repr;
89}
90
91} // namespace SVF
newitem type
Definition cJSON.cpp:2739
const SVFType * typeOfElement
For printing & debugging.
Definition SVFType.h:486
unsigned numOfElement
Definition SVFType.h:485
void print(std::ostream &os) const override
Definition SVFType.cpp:81
const SVFType * getReturnType() const
Definition SVFType.h:401
bool isVarArg() const
Definition SVFType.h:411
std::vector< const SVFType * > params
Definition SVFType.h:374
void print(std::ostream &os) const override
Definition SVFType.cpp:36
short signAndWidth
For printing.
Definition SVFType.h:339
void print(std::ostream &os) const override
Definition SVFType.cpp:28
void print(std::ostream &os) const override
Definition SVFType.cpp:86
std::string repr
Definition SVFType.h:530
void print(std::ostream &os) const override
Definition SVFType.cpp:23
std::string name
Field for printing & debugging.
Definition SVFType.h:437
std::vector< const SVFType * > fields
Definition SVFType.h:438
void print(std::ostream &os) const override
Definition SVFType.cpp:64
static SVFType * svfPtrTy
ptr type
Definition SVFType.h:230
std::string toString() const
Definition SVFType.cpp:10
static SVFType * svfI8Ty
8-bit int type
Definition SVFType.h:231
virtual void print(std::ostream &os) const =0
for isBitcode
Definition BasicTypes.h:70
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76
IntervalValue operator<<(const IntervalValue &lhs, const IntervalValue &rhs)
Left binary shift of IntervalValues.