File indexing completed on 2026-05-10 08:44:10
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef LLVM_IR_TYPEFINDER_H
0014 #define LLVM_IR_TYPEFINDER_H
0015
0016 #include "llvm/ADT/DenseSet.h"
0017 #include "llvm/IR/Attributes.h"
0018 #include <cstddef>
0019 #include <vector>
0020
0021 namespace llvm {
0022
0023 class MDNode;
0024 class Module;
0025 class StructType;
0026 class Type;
0027 class Value;
0028
0029
0030
0031 class TypeFinder {
0032
0033
0034 DenseSet<const Value*> VisitedConstants;
0035 DenseSet<const MDNode *> VisitedMetadata;
0036 DenseSet<AttributeList> VisitedAttributes;
0037 DenseSet<Type*> VisitedTypes;
0038
0039 std::vector<StructType*> StructTypes;
0040 bool OnlyNamed = false;
0041
0042 public:
0043 TypeFinder() = default;
0044
0045 void run(const Module &M, bool onlyNamed);
0046 void clear();
0047
0048 using iterator = std::vector<StructType*>::iterator;
0049 using const_iterator = std::vector<StructType*>::const_iterator;
0050
0051 iterator begin() { return StructTypes.begin(); }
0052 iterator end() { return StructTypes.end(); }
0053
0054 const_iterator begin() const { return StructTypes.begin(); }
0055 const_iterator end() const { return StructTypes.end(); }
0056
0057 bool empty() const { return StructTypes.empty(); }
0058 size_t size() const { return StructTypes.size(); }
0059 iterator erase(iterator I, iterator E) { return StructTypes.erase(I, E); }
0060
0061 StructType *&operator[](unsigned Idx) { return StructTypes[Idx]; }
0062
0063 DenseSet<const MDNode *> &getVisitedMetadata() { return VisitedMetadata; }
0064
0065 private:
0066
0067
0068 void incorporateType(Type *Ty);
0069
0070
0071
0072
0073
0074 void incorporateValue(const Value *V);
0075
0076
0077
0078 void incorporateMDNode(const MDNode *V);
0079
0080
0081 void incorporateAttributes(AttributeList AL);
0082 };
0083
0084 }
0085
0086 #endif