@@ -133,41 +133,40 @@ class ErrorReporter {
133
133
for (const auto &Repl : FileAndReplacements.second ) {
134
134
++TotalFixes;
135
135
bool CanBeApplied = false ;
136
- if (Repl.isApplicable ()) {
137
- SourceLocation FixLoc;
138
- SmallString<128 > FixAbsoluteFilePath = Repl.getFilePath ();
139
- Files.makeAbsolutePath (FixAbsoluteFilePath);
140
- tooling::Replacement R (FixAbsoluteFilePath, Repl.getOffset (),
141
- Repl.getLength (),
142
- Repl.getReplacementText ());
143
- Replacements &Replacements = FileReplacements[R.getFilePath ()];
144
- llvm::Error Err = Replacements.add (R);
145
- if (Err) {
146
- // FIXME: Implement better conflict handling.
147
- llvm::errs () << " Trying to resolve conflict: "
148
- << llvm::toString (std::move (Err)) << " \n " ;
149
- unsigned NewOffset =
150
- Replacements.getShiftedCodePosition (R.getOffset ());
151
- unsigned NewLength = Replacements.getShiftedCodePosition (
152
- R.getOffset () + R.getLength ()) -
153
- NewOffset;
154
- if (NewLength == R.getLength ()) {
155
- R = Replacement (R.getFilePath (), NewOffset, NewLength,
156
- R.getReplacementText ());
157
- Replacements = Replacements.merge (tooling::Replacements (R));
158
- CanBeApplied = true ;
159
- ++AppliedFixes;
160
- } else {
161
- llvm::errs ()
162
- << " Can't resolve conflict, skipping the replacement.\n " ;
163
- }
164
- } else {
136
+ if (!Repl.isApplicable ())
137
+ continue ;
138
+ SourceLocation FixLoc;
139
+ SmallString<128 > FixAbsoluteFilePath = Repl.getFilePath ();
140
+ Files.makeAbsolutePath (FixAbsoluteFilePath);
141
+ tooling::Replacement R (FixAbsoluteFilePath, Repl.getOffset (),
142
+ Repl.getLength (), Repl.getReplacementText ());
143
+ Replacements &Replacements = FileReplacements[R.getFilePath ()];
144
+ llvm::Error Err = Replacements.add (R);
145
+ if (Err) {
146
+ // FIXME: Implement better conflict handling.
147
+ llvm::errs () << " Trying to resolve conflict: "
148
+ << llvm::toString (std::move (Err)) << " \n " ;
149
+ unsigned NewOffset =
150
+ Replacements.getShiftedCodePosition (R.getOffset ());
151
+ unsigned NewLength = Replacements.getShiftedCodePosition (
152
+ R.getOffset () + R.getLength ()) -
153
+ NewOffset;
154
+ if (NewLength == R.getLength ()) {
155
+ R = Replacement (R.getFilePath (), NewOffset, NewLength,
156
+ R.getReplacementText ());
157
+ Replacements = Replacements.merge (tooling::Replacements (R));
165
158
CanBeApplied = true ;
166
159
++AppliedFixes;
160
+ } else {
161
+ llvm::errs ()
162
+ << " Can't resolve conflict, skipping the replacement.\n " ;
167
163
}
168
- FixLoc = getLocation (FixAbsoluteFilePath, Repl.getOffset ());
169
- FixLocations.push_back (std::make_pair (FixLoc, CanBeApplied));
164
+ } else {
165
+ CanBeApplied = true ;
166
+ ++AppliedFixes;
170
167
}
168
+ FixLoc = getLocation (FixAbsoluteFilePath, Repl.getOffset ());
169
+ FixLocations.push_back (std::make_pair (FixLoc, CanBeApplied));
171
170
}
172
171
}
173
172
}
0 commit comments