-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[NFC] Reformat ClangASTPropertiesEmitter ASTPropsEmitter
class
#108275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is in preparation of #108274 which touches this class and end up reformatting a bunch of untouched code in the process. |
I just left indented the code in that class and then ran |
@llvm/pr-subscribers-clang Author: Rahul Joshi (jurahul) ChangesFull diff: https://github.com/llvm/llvm-project/pull/108275.diff 1 Files Affected:
diff --git a/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp b/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
index de8dda60681ff8..70005da28559d3 100644
--- a/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
+++ b/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
@@ -88,99 +88,98 @@ struct CasedTypeInfo {
};
class ASTPropsEmitter {
- raw_ostream &Out;
- RecordKeeper &Records;
- std::map<HasProperties, NodeInfo> NodeInfos;
+ raw_ostream &Out;
+ RecordKeeper &Records;
+ std::map<HasProperties, NodeInfo> NodeInfos;
std::vector<PropertyType> AllPropertyTypes;
std::map<PropertyType, CasedTypeInfo> CasedTypeInfos;
public:
- ASTPropsEmitter(RecordKeeper &records, raw_ostream &out)
- : Out(out), Records(records) {
-
- // Find all the properties.
- for (Property property :
- records.getAllDerivedDefinitions(PropertyClassName)) {
- HasProperties node = property.getClass();
- NodeInfos[node].Properties.push_back(property);
- }
+ ASTPropsEmitter(RecordKeeper &records, raw_ostream &out)
+ : Out(out), Records(records) {
+
+ // Find all the properties.
+ for (Property property :
+ records.getAllDerivedDefinitions(PropertyClassName)) {
+ HasProperties node = property.getClass();
+ NodeInfos[node].Properties.push_back(property);
+ }
// Find all the creation rules.
for (CreationRule creationRule :
- records.getAllDerivedDefinitions(CreationRuleClassName)) {
+ records.getAllDerivedDefinitions(CreationRuleClassName)) {
HasProperties node = creationRule.getClass();
auto &info = NodeInfos[node];
if (info.Creator) {
- PrintFatalError(creationRule.getLoc(),
- "multiple creator rules for \"" + node.getName()
- + "\"");
+ PrintFatalError(creationRule.getLoc(), "multiple creator rules for \"" +
+ node.getName() + "\"");
}
info.Creator = creationRule;
}
// Find all the override rules.
for (OverrideRule overrideRule :
- records.getAllDerivedDefinitions(OverrideRuleClassName)) {
+ records.getAllDerivedDefinitions(OverrideRuleClassName)) {
HasProperties node = overrideRule.getClass();
auto &info = NodeInfos[node];
if (info.Override) {
PrintFatalError(overrideRule.getLoc(),
- "multiple override rules for \"" + node.getName()
- + "\"");
+ "multiple override rules for \"" + node.getName() +
+ "\"");
}
info.Override = overrideRule;
}
// Find all the write helper rules.
for (ReadHelperRule helperRule :
- records.getAllDerivedDefinitions(ReadHelperRuleClassName)) {
+ records.getAllDerivedDefinitions(ReadHelperRuleClassName)) {
HasProperties node = helperRule.getClass();
auto &info = NodeInfos[node];
if (info.ReadHelper) {
PrintFatalError(helperRule.getLoc(),
- "multiple write helper rules for \"" + node.getName()
- + "\"");
+ "multiple write helper rules for \"" + node.getName() +
+ "\"");
}
info.ReadHelper = helperRule;
}
// Find all the concrete property types.
for (PropertyType type :
- records.getAllDerivedDefinitions(PropertyTypeClassName)) {
+ records.getAllDerivedDefinitions(PropertyTypeClassName)) {
// Ignore generic specializations; they're generally not useful when
// emitting basic emitters etc.
- if (type.isGenericSpecialization()) continue;
+ if (type.isGenericSpecialization())
+ continue;
AllPropertyTypes.push_back(type);
}
// Find all the type kind rules.
for (TypeKindRule kindRule :
- records.getAllDerivedDefinitions(TypeKindClassName)) {
+ records.getAllDerivedDefinitions(TypeKindClassName)) {
PropertyType type = kindRule.getParentType();
auto &info = CasedTypeInfos[type];
if (info.KindRule) {
- PrintFatalError(kindRule.getLoc(),
- "multiple kind rules for \""
- + type.getCXXTypeName() + "\"");
+ PrintFatalError(kindRule.getLoc(), "multiple kind rules for \"" +
+ type.getCXXTypeName() + "\"");
}
info.KindRule = kindRule;
}
// Find all the type cases.
for (TypeCase typeCase :
- records.getAllDerivedDefinitions(TypeCaseClassName)) {
+ records.getAllDerivedDefinitions(TypeCaseClassName)) {
CasedTypeInfos[typeCase.getParentType()].Cases.push_back(typeCase);
}
Validator(*this).validate();
- }
+ }
void visitAllProperties(HasProperties derived, const NodeInfo &derivedInfo,
- function_ref<void (Property)> visit) {
+ function_ref<void(Property)> visit) {
std::set<StringRef> ignoredProperties;
auto overrideRule = derivedInfo.Override;
@@ -195,20 +194,19 @@ class ASTPropsEmitter {
visitAllNodesWithInfo(derived, derivedInfo,
[&](HasProperties node, const NodeInfo &info) {
- for (Property prop : info.Properties) {
- if (ignoredProperties.count(prop.getName()))
- continue;
+ for (Property prop : info.Properties) {
+ if (ignoredProperties.count(prop.getName()))
+ continue;
- visit(prop);
- }
- });
+ visit(prop);
+ }
+ });
}
- void visitAllNodesWithInfo(HasProperties derivedNode,
- const NodeInfo &derivedNodeInfo,
- llvm::function_ref<void (HasProperties node,
- const NodeInfo &info)>
- visit) {
+ void visitAllNodesWithInfo(
+ HasProperties derivedNode, const NodeInfo &derivedNodeInfo,
+ llvm::function_ref<void(HasProperties node, const NodeInfo &info)>
+ visit) {
visit(derivedNode, derivedNodeInfo);
// Also walk the bases if appropriate.
@@ -217,7 +215,8 @@ class ASTPropsEmitter {
auto it = NodeInfos.find(base);
// Ignore intermediate nodes that don't add interesting properties.
- if (it == NodeInfos.end()) continue;
+ if (it == NodeInfos.end())
+ continue;
auto &baseInfo = it->second;
visit(base, baseInfo);
@@ -225,14 +224,12 @@ class ASTPropsEmitter {
}
}
- template <class NodeClass>
- void emitNodeReaderClass() {
+ template <class NodeClass> void emitNodeReaderClass() {
auto info = ReaderWriterInfo::forReader<NodeClass>();
emitNodeReaderWriterClass<NodeClass>(info);
}
- template <class NodeClass>
- void emitNodeWriterClass() {
+ template <class NodeClass> void emitNodeWriterClass() {
auto info = ReaderWriterInfo::forWriter<NodeClass>();
emitNodeReaderWriterClass<NodeClass>(info);
}
@@ -241,8 +238,7 @@ class ASTPropsEmitter {
void emitNodeReaderWriterClass(const ReaderWriterInfo &info);
template <class NodeClass>
- void emitNodeReaderWriterMethod(NodeClass node,
- const ReaderWriterInfo &info);
+ void emitNodeReaderWriterMethod(NodeClass node, const ReaderWriterInfo &info);
void emitPropertiedReaderWriterBody(HasProperties node,
const ReaderWriterInfo &info);
|
kazutakahirata
approved these changes
Sep 11, 2024
Thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.