@@ -126,39 +126,51 @@ void RewriteSystem::propagateRedundantRequirementIDs() {
126
126
llvm::dbgs () << " \n Propagating requirement IDs: {" ;
127
127
}
128
128
129
- for (auto ruleAndReplacement : RedundantRules) {
130
- auto ruleID = ruleAndReplacement.first ;
131
- auto rewritePath = ruleAndReplacement.second ;
132
- auto &rule = Rules[ruleID];
129
+ for (const auto & ruleAndReplacement : RedundantRules) {
130
+ unsigned ruleID = ruleAndReplacement.first ;
131
+ const auto & rewritePath = ruleAndReplacement.second ;
132
+ const auto &rule = Rules[ruleID];
133
133
134
134
auto requirementID = rule.getRequirementID ();
135
- if (!requirementID.hasValue ())
135
+ if (!requirementID.hasValue ()) {
136
+ if (Debug.contains (DebugFlags::PropagateRequirementIDs)) {
137
+ llvm::dbgs () << " \n - rule does not have a requirement ID: "
138
+ << rule;
139
+ }
136
140
continue ;
141
+ }
137
142
138
143
MutableTerm lhs (rule.getLHS ());
139
144
for (auto ruleID : rewritePath.findRulesAppearingOnceInEmptyContext (lhs, *this )) {
140
145
auto &replacement = Rules[ruleID];
141
- if (!replacement.isPermanent ()) {
142
- // If the replacement rule already has a requirementID, overwrite
143
- // it if the existing ID corresponds to an inferred requirement.
144
- // This effectively makes the inferred requirement the redundant
145
- // one, which makes it easier to suppress redundancy warnings for
146
- // inferred requirements later on.
147
- auto existingID = replacement.getRequirementID ();
148
- if (existingID.hasValue () && !WrittenRequirements[*existingID].inferred )
149
- continue ;
146
+ if (replacement.isPermanent ()) {
147
+ if (Debug.contains (DebugFlags::PropagateRequirementIDs)) {
148
+ llvm::dbgs () << " \n - skipping permanent rule: " << rule;
149
+ }
150
+ continue ;
151
+ }
150
152
153
+ // If the replacement rule already has a requirementID, overwrite
154
+ // it if the existing ID corresponds to an inferred requirement.
155
+ // This effectively makes the inferred requirement the redundant
156
+ // one, which makes it easier to suppress redundancy warnings for
157
+ // inferred requirements later on.
158
+ auto existingID = replacement.getRequirementID ();
159
+ if (existingID.hasValue () && !WrittenRequirements[*existingID].inferred ) {
151
160
if (Debug.contains (DebugFlags::PropagateRequirementIDs)) {
152
- llvm::dbgs () << " \n - propagating ID = "
153
- << requirementID
154
- << " \n from " ;
155
- rule.dump (llvm::dbgs ());
156
- llvm::dbgs () << " \n to " ;
157
- replacement.dump (llvm::dbgs ());
161
+ llvm::dbgs () << " \n - rule already has a requirement ID: "
162
+ << rule;
158
163
}
164
+ continue ;
165
+ }
159
166
160
- replacement.setRequirementID (requirementID);
167
+ if (Debug.contains (DebugFlags::PropagateRequirementIDs)) {
168
+ llvm::dbgs () << " \n - propagating ID = " << requirementID
169
+ << " \n from " << rule;
170
+ llvm::dbgs () << " \n to " << replacement;
161
171
}
172
+
173
+ replacement.setRequirementID (requirementID);
162
174
}
163
175
}
164
176
0 commit comments