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
11std::string SVFType::toString() const
12{
13 std::ostringstream os;
14 print(os);
15 return os.str();
16}
17
18std::ostream& operator<<(std::ostream& os, const SVFType& type)
19{
20 type.print(os);
21 return os;
22}
23
24void SVFPointerType::print(std::ostream& os) const
25{
26 os << "ptr";
27}
28
29void SVFIntegerType::print(std::ostream& os) const
30{
31 if (signAndWidth < 0)
32 os << 'i' << -signAndWidth;
33 else
34 os << 'u' << signAndWidth;
35}
36
37void SVFFunctionType::print(std::ostream& os) const
38{
39 os << *getReturnType() << "(";
40
41 // Print parameters
42 for (size_t i = 0; i < params.size(); ++i)
43 {
44 os << *params[i];
45 // Add comma after all params except the last one
46 if (i != params.size() - 1)
47 {
48 os << ", ";
49 }
50 }
51
52 // Add varargs indicator if needed
53 if (isVarArg())
54 {
55 if (!params.empty())
56 {
57 os << ", ";
58 }
59 os << "...";
60 }
61
62 os << ")";
63}
64
65void SVFStructType::print(std::ostream& os) const
66{
67 os << "S." << name << " {";
68
69 // Print fields
70 for (size_t i = 0; i < fields.size(); ++i)
71 {
72 os << *fields[i];
73 // Add comma after all fields except the last one
74 if (i != fields.size() - 1)
75 {
76 os << ", ";
77 }
78 }
79 os << "}";
80}
81
82void SVFArrayType::print(std::ostream& os) const
83{
84 os << '[' << numOfElement << 'x' << *typeOfElement << ']';
85}
86
87void SVFOtherType::print(std::ostream& os) const
88{
89 os << repr;
90}
91
92} // namespace SVF
newitem type
Definition cJSON.cpp:2739
const SVFType * typeOfElement
For printing & debugging.
Definition SVFType.h:412
unsigned numOfElement
Definition SVFType.h:411
void print(std::ostream &os) const override
Definition SVFType.cpp:82
const SVFType * getReturnType() const
Definition SVFType.h:344
bool isVarArg() const
Definition SVFType.h:355
std::vector< const SVFType * > params
Definition SVFType.h:331
void print(std::ostream &os) const override
Definition SVFType.cpp:37
short signAndWidth
For printing.
Definition SVFType.h:302
void print(std::ostream &os) const override
Definition SVFType.cpp:29
void print(std::ostream &os) const override
Definition SVFType.cpp:87
std::string repr
Definition SVFType.h:451
void print(std::ostream &os) const override
Definition SVFType.cpp:24
std::string name
Field for printing & debugging.
Definition SVFType.h:370
std::vector< const SVFType * > fields
Definition SVFType.h:371
void print(std::ostream &os) const override
Definition SVFType.cpp:65
static SVFType * svfPtrTy
ptr type
Definition SVFType.h:192
std::string toString() const
static SVFType * svfI8Ty
8-bit int type
Definition SVFType.h:193
virtual void print(std::ostream &os) const =0
for isBitcode
Definition BasicTypes.h:68
__attribute__((weak)) std
Definition SVFType.cpp:10
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74
IntervalValue operator<<(const IntervalValue &lhs, const IntervalValue &rhs)
Left binary shift of IntervalValues.