@@ -88,99 +88,98 @@ struct CasedTypeInfo {
88
88
};
89
89
90
90
class ASTPropsEmitter {
91
- raw_ostream &Out;
92
- RecordKeeper &Records;
93
- std::map<HasProperties, NodeInfo> NodeInfos;
91
+ raw_ostream &Out;
92
+ RecordKeeper &Records;
93
+ std::map<HasProperties, NodeInfo> NodeInfos;
94
94
std::vector<PropertyType> AllPropertyTypes;
95
95
std::map<PropertyType, CasedTypeInfo> CasedTypeInfos;
96
96
97
97
public:
98
- ASTPropsEmitter (RecordKeeper &records, raw_ostream &out)
99
- : Out(out), Records(records) {
100
-
101
- // Find all the properties.
102
- for (Property property :
103
- records.getAllDerivedDefinitions (PropertyClassName)) {
104
- HasProperties node = property.getClass ();
105
- NodeInfos[node].Properties .push_back (property);
106
- }
98
+ ASTPropsEmitter (RecordKeeper &records, raw_ostream &out)
99
+ : Out(out), Records(records) {
100
+
101
+ // Find all the properties.
102
+ for (Property property :
103
+ records.getAllDerivedDefinitions (PropertyClassName)) {
104
+ HasProperties node = property.getClass ();
105
+ NodeInfos[node].Properties .push_back (property);
106
+ }
107
107
108
108
// Find all the creation rules.
109
109
for (CreationRule creationRule :
110
- records.getAllDerivedDefinitions (CreationRuleClassName)) {
110
+ records.getAllDerivedDefinitions (CreationRuleClassName)) {
111
111
HasProperties node = creationRule.getClass ();
112
112
113
113
auto &info = NodeInfos[node];
114
114
if (info.Creator ) {
115
- PrintFatalError (creationRule.getLoc (),
116
- " multiple creator rules for \" " + node.getName ()
117
- + " \" " );
115
+ PrintFatalError (creationRule.getLoc (), " multiple creator rules for \" " +
116
+ node.getName () + " \" " );
118
117
}
119
118
info.Creator = creationRule;
120
119
}
121
120
122
121
// Find all the override rules.
123
122
for (OverrideRule overrideRule :
124
- records.getAllDerivedDefinitions (OverrideRuleClassName)) {
123
+ records.getAllDerivedDefinitions (OverrideRuleClassName)) {
125
124
HasProperties node = overrideRule.getClass ();
126
125
127
126
auto &info = NodeInfos[node];
128
127
if (info.Override ) {
129
128
PrintFatalError (overrideRule.getLoc (),
130
- " multiple override rules for \" " + node.getName ()
131
- + " \" " );
129
+ " multiple override rules for \" " + node.getName () +
130
+ " \" " );
132
131
}
133
132
info.Override = overrideRule;
134
133
}
135
134
136
135
// Find all the write helper rules.
137
136
for (ReadHelperRule helperRule :
138
- records.getAllDerivedDefinitions (ReadHelperRuleClassName)) {
137
+ records.getAllDerivedDefinitions (ReadHelperRuleClassName)) {
139
138
HasProperties node = helperRule.getClass ();
140
139
141
140
auto &info = NodeInfos[node];
142
141
if (info.ReadHelper ) {
143
142
PrintFatalError (helperRule.getLoc (),
144
- " multiple write helper rules for \" " + node.getName ()
145
- + " \" " );
143
+ " multiple write helper rules for \" " + node.getName () +
144
+ " \" " );
146
145
}
147
146
info.ReadHelper = helperRule;
148
147
}
149
148
150
149
// Find all the concrete property types.
151
150
for (PropertyType type :
152
- records.getAllDerivedDefinitions (PropertyTypeClassName)) {
151
+ records.getAllDerivedDefinitions (PropertyTypeClassName)) {
153
152
// Ignore generic specializations; they're generally not useful when
154
153
// emitting basic emitters etc.
155
- if (type.isGenericSpecialization ()) continue ;
154
+ if (type.isGenericSpecialization ())
155
+ continue ;
156
156
157
157
AllPropertyTypes.push_back (type);
158
158
}
159
159
160
160
// Find all the type kind rules.
161
161
for (TypeKindRule kindRule :
162
- records.getAllDerivedDefinitions (TypeKindClassName)) {
162
+ records.getAllDerivedDefinitions (TypeKindClassName)) {
163
163
PropertyType type = kindRule.getParentType ();
164
164
auto &info = CasedTypeInfos[type];
165
165
if (info.KindRule ) {
166
- PrintFatalError (kindRule.getLoc (),
167
- " multiple kind rules for \" "
168
- + type.getCXXTypeName () + " \" " );
166
+ PrintFatalError (kindRule.getLoc (), " multiple kind rules for \" " +
167
+ type.getCXXTypeName () + " \" " );
169
168
}
170
169
info.KindRule = kindRule;
171
170
}
172
171
173
172
// Find all the type cases.
174
173
for (TypeCase typeCase :
175
- records.getAllDerivedDefinitions (TypeCaseClassName)) {
174
+ records.getAllDerivedDefinitions (TypeCaseClassName)) {
176
175
CasedTypeInfos[typeCase.getParentType ()].Cases .push_back (typeCase);
177
176
}
178
177
179
178
Validator (*this ).validate ();
180
- }
179
+ }
181
180
182
181
void visitAllProperties (HasProperties derived, const NodeInfo &derivedInfo,
183
- function_ref<void (Property)> visit) {
182
+ function_ref<void (Property)> visit) {
184
183
std::set<StringRef> ignoredProperties;
185
184
186
185
auto overrideRule = derivedInfo.Override ;
@@ -195,20 +194,19 @@ class ASTPropsEmitter {
195
194
196
195
visitAllNodesWithInfo (derived, derivedInfo,
197
196
[&](HasProperties node, const NodeInfo &info) {
198
- for (Property prop : info.Properties ) {
199
- if (ignoredProperties.count (prop.getName ()))
200
- continue ;
197
+ for (Property prop : info.Properties ) {
198
+ if (ignoredProperties.count (prop.getName ()))
199
+ continue ;
201
200
202
- visit (prop);
203
- }
204
- });
201
+ visit (prop);
202
+ }
203
+ });
205
204
}
206
205
207
- void visitAllNodesWithInfo (HasProperties derivedNode,
208
- const NodeInfo &derivedNodeInfo,
209
- llvm::function_ref<void (HasProperties node,
210
- const NodeInfo &info)>
211
- visit) {
206
+ void visitAllNodesWithInfo (
207
+ HasProperties derivedNode, const NodeInfo &derivedNodeInfo,
208
+ llvm::function_ref<void (HasProperties node, const NodeInfo &info)>
209
+ visit) {
212
210
visit (derivedNode, derivedNodeInfo);
213
211
214
212
// Also walk the bases if appropriate.
@@ -217,22 +215,21 @@ class ASTPropsEmitter {
217
215
auto it = NodeInfos.find (base);
218
216
219
217
// Ignore intermediate nodes that don't add interesting properties.
220
- if (it == NodeInfos.end ()) continue ;
218
+ if (it == NodeInfos.end ())
219
+ continue ;
221
220
auto &baseInfo = it->second ;
222
221
223
222
visit (base, baseInfo);
224
223
}
225
224
}
226
225
}
227
226
228
- template <class NodeClass >
229
- void emitNodeReaderClass () {
227
+ template <class NodeClass > void emitNodeReaderClass () {
230
228
auto info = ReaderWriterInfo::forReader<NodeClass>();
231
229
emitNodeReaderWriterClass<NodeClass>(info);
232
230
}
233
231
234
- template <class NodeClass >
235
- void emitNodeWriterClass () {
232
+ template <class NodeClass > void emitNodeWriterClass () {
236
233
auto info = ReaderWriterInfo::forWriter<NodeClass>();
237
234
emitNodeReaderWriterClass<NodeClass>(info);
238
235
}
@@ -241,8 +238,7 @@ class ASTPropsEmitter {
241
238
void emitNodeReaderWriterClass (const ReaderWriterInfo &info);
242
239
243
240
template <class NodeClass >
244
- void emitNodeReaderWriterMethod (NodeClass node,
245
- const ReaderWriterInfo &info);
241
+ void emitNodeReaderWriterMethod (NodeClass node, const ReaderWriterInfo &info);
246
242
247
243
void emitPropertiedReaderWriterBody (HasProperties node,
248
244
const ReaderWriterInfo &info);
0 commit comments