@@ -99,22 +99,20 @@ bool TreeVisitor::VisitRecordDecl(clang::RecordDecl *record) {
99
99
}
100
100
101
101
void TreeVisitor::handleUnion (clang::RecordDecl *record, std::string name) {
102
- uint64_t maxSize = 0 ;
103
-
104
102
std::vector<std::shared_ptr<Field>> fields;
105
103
106
104
for (const clang::FieldDecl *field : record->fields ()) {
107
- uint64_t sizeInBits = astContext->getTypeSize (field->getType ());
108
- assert (sizeInBits % 8 == 0 );
109
- maxSize = std::max (maxSize, sizeInBits / 8 );
110
105
std::string fname = field->getNameAsString ();
111
106
std::shared_ptr<Type> ftype =
112
107
typeTranslator.translate (field->getType (), &name);
113
108
114
109
fields.push_back (std::make_shared<Field>(fname, ftype));
115
110
}
116
111
117
- ir.addUnion (name, std::move (fields), maxSize, getLocation (record));
112
+ uint64_t sizeInBits = astContext->getTypeSize (record->getTypeForDecl ());
113
+ assert (sizeInBits % 8 == 0 );
114
+
115
+ ir.addUnion (name, std::move (fields), sizeInBits / 8 , getLocation (record));
118
116
}
119
117
120
118
void TreeVisitor::handleStruct (clang::RecordDecl *record, std::string name) {
@@ -127,7 +125,6 @@ void TreeVisitor::handleStruct(clang::RecordDecl *record, std::string name) {
127
125
llvm::errs ().flush ();
128
126
}
129
127
130
- int fieldCnt = 0 ;
131
128
std::vector<std::shared_ptr<Field>> fields;
132
129
133
130
for (const clang::FieldDecl *field : record->fields ()) {
@@ -137,8 +134,6 @@ void TreeVisitor::handleStruct(clang::RecordDecl *record, std::string name) {
137
134
std::make_shared<Field>(field->getNameAsString (), ftype));
138
135
139
136
cycleDetection.AddDependency (newName, field->getType ());
140
-
141
- fieldCnt++;
142
137
}
143
138
144
139
if (cycleDetection.isCyclic (newName)) {
0 commit comments