Skip to content

Commit f5abdfd

Browse files
committed
[NFC][SpecialCaseList] Refactor error handling
Will help in future patches. Pull Request: llvm#167277
1 parent 61948d2 commit f5abdfd

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

llvm/lib/Support/SpecialCaseList.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,12 @@ bool SpecialCaseList::parse(unsigned FileIdx, const MemoryBuffer *MB,
274274

275275
bool RemoveDotSlash = Version > 2;
276276

277-
Section *CurrentSection;
278-
if (auto Err = addSection("*", FileIdx, 1, true).moveInto(CurrentSection)) {
277+
auto ErrOrSection = addSection("*", FileIdx, 1, true);
278+
if (auto Err = ErrOrSection.takeError()) {
279279
Error = toString(std::move(Err));
280280
return false;
281281
}
282+
Section *CurrentSection = ErrOrSection.get();
282283

283284
// This is the current list of prefixes for all existing users matching file
284285
// path. We may need parametrization in constructor in future.
@@ -300,12 +301,13 @@ bool SpecialCaseList::parse(unsigned FileIdx, const MemoryBuffer *MB,
300301
return false;
301302
}
302303

303-
if (auto Err = addSection(Line.drop_front().drop_back(), FileIdx, LineNo,
304-
UseGlobs)
305-
.moveInto(CurrentSection)) {
304+
auto ErrOrSection =
305+
addSection(Line.drop_front().drop_back(), FileIdx, LineNo, UseGlobs);
306+
if (auto Err = ErrOrSection.takeError()) {
306307
Error = toString(std::move(Err));
307308
return false;
308309
}
310+
CurrentSection = ErrOrSection.get();
309311
continue;
310312
}
311313

0 commit comments

Comments
 (0)