Skip to content

Commit c98d6c2

Browse files
authored
[NFC] Reformat ClangASTPropertiesEmitter ASTPropsEmitter class (#108275)
1 parent 31d4837 commit c98d6c2

File tree

1 file changed

+45
-49
lines changed

1 file changed

+45
-49
lines changed

clang/utils/TableGen/ClangASTPropertiesEmitter.cpp

Lines changed: 45 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -88,99 +88,98 @@ struct CasedTypeInfo {
8888
};
8989

9090
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;
9494
std::vector<PropertyType> AllPropertyTypes;
9595
std::map<PropertyType, CasedTypeInfo> CasedTypeInfos;
9696

9797
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+
}
107107

108108
// Find all the creation rules.
109109
for (CreationRule creationRule :
110-
records.getAllDerivedDefinitions(CreationRuleClassName)) {
110+
records.getAllDerivedDefinitions(CreationRuleClassName)) {
111111
HasProperties node = creationRule.getClass();
112112

113113
auto &info = NodeInfos[node];
114114
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() + "\"");
118117
}
119118
info.Creator = creationRule;
120119
}
121120

122121
// Find all the override rules.
123122
for (OverrideRule overrideRule :
124-
records.getAllDerivedDefinitions(OverrideRuleClassName)) {
123+
records.getAllDerivedDefinitions(OverrideRuleClassName)) {
125124
HasProperties node = overrideRule.getClass();
126125

127126
auto &info = NodeInfos[node];
128127
if (info.Override) {
129128
PrintFatalError(overrideRule.getLoc(),
130-
"multiple override rules for \"" + node.getName()
131-
+ "\"");
129+
"multiple override rules for \"" + node.getName() +
130+
"\"");
132131
}
133132
info.Override = overrideRule;
134133
}
135134

136135
// Find all the write helper rules.
137136
for (ReadHelperRule helperRule :
138-
records.getAllDerivedDefinitions(ReadHelperRuleClassName)) {
137+
records.getAllDerivedDefinitions(ReadHelperRuleClassName)) {
139138
HasProperties node = helperRule.getClass();
140139

141140
auto &info = NodeInfos[node];
142141
if (info.ReadHelper) {
143142
PrintFatalError(helperRule.getLoc(),
144-
"multiple write helper rules for \"" + node.getName()
145-
+ "\"");
143+
"multiple write helper rules for \"" + node.getName() +
144+
"\"");
146145
}
147146
info.ReadHelper = helperRule;
148147
}
149148

150149
// Find all the concrete property types.
151150
for (PropertyType type :
152-
records.getAllDerivedDefinitions(PropertyTypeClassName)) {
151+
records.getAllDerivedDefinitions(PropertyTypeClassName)) {
153152
// Ignore generic specializations; they're generally not useful when
154153
// emitting basic emitters etc.
155-
if (type.isGenericSpecialization()) continue;
154+
if (type.isGenericSpecialization())
155+
continue;
156156

157157
AllPropertyTypes.push_back(type);
158158
}
159159

160160
// Find all the type kind rules.
161161
for (TypeKindRule kindRule :
162-
records.getAllDerivedDefinitions(TypeKindClassName)) {
162+
records.getAllDerivedDefinitions(TypeKindClassName)) {
163163
PropertyType type = kindRule.getParentType();
164164
auto &info = CasedTypeInfos[type];
165165
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() + "\"");
169168
}
170169
info.KindRule = kindRule;
171170
}
172171

173172
// Find all the type cases.
174173
for (TypeCase typeCase :
175-
records.getAllDerivedDefinitions(TypeCaseClassName)) {
174+
records.getAllDerivedDefinitions(TypeCaseClassName)) {
176175
CasedTypeInfos[typeCase.getParentType()].Cases.push_back(typeCase);
177176
}
178177

179178
Validator(*this).validate();
180-
}
179+
}
181180

182181
void visitAllProperties(HasProperties derived, const NodeInfo &derivedInfo,
183-
function_ref<void (Property)> visit) {
182+
function_ref<void(Property)> visit) {
184183
std::set<StringRef> ignoredProperties;
185184

186185
auto overrideRule = derivedInfo.Override;
@@ -195,20 +194,19 @@ class ASTPropsEmitter {
195194

196195
visitAllNodesWithInfo(derived, derivedInfo,
197196
[&](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;
201200

202-
visit(prop);
203-
}
204-
});
201+
visit(prop);
202+
}
203+
});
205204
}
206205

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) {
212210
visit(derivedNode, derivedNodeInfo);
213211

214212
// Also walk the bases if appropriate.
@@ -217,22 +215,21 @@ class ASTPropsEmitter {
217215
auto it = NodeInfos.find(base);
218216

219217
// Ignore intermediate nodes that don't add interesting properties.
220-
if (it == NodeInfos.end()) continue;
218+
if (it == NodeInfos.end())
219+
continue;
221220
auto &baseInfo = it->second;
222221

223222
visit(base, baseInfo);
224223
}
225224
}
226225
}
227226

228-
template <class NodeClass>
229-
void emitNodeReaderClass() {
227+
template <class NodeClass> void emitNodeReaderClass() {
230228
auto info = ReaderWriterInfo::forReader<NodeClass>();
231229
emitNodeReaderWriterClass<NodeClass>(info);
232230
}
233231

234-
template <class NodeClass>
235-
void emitNodeWriterClass() {
232+
template <class NodeClass> void emitNodeWriterClass() {
236233
auto info = ReaderWriterInfo::forWriter<NodeClass>();
237234
emitNodeReaderWriterClass<NodeClass>(info);
238235
}
@@ -241,8 +238,7 @@ class ASTPropsEmitter {
241238
void emitNodeReaderWriterClass(const ReaderWriterInfo &info);
242239

243240
template <class NodeClass>
244-
void emitNodeReaderWriterMethod(NodeClass node,
245-
const ReaderWriterInfo &info);
241+
void emitNodeReaderWriterMethod(NodeClass node, const ReaderWriterInfo &info);
246242

247243
void emitPropertiedReaderWriterBody(HasProperties node,
248244
const ReaderWriterInfo &info);

0 commit comments

Comments
 (0)