[llvm] [llvm][Support][NFC] Disentangle SpecialCaseList parsing and matching (PR #116800)
Boaz Brickner via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 20 04:17:26 PST 2024
================
@@ -113,22 +120,49 @@ bool SpecialCaseList::createInternal(const std::vector<std::string> &Paths,
Error = (Twine("can't open file '") + Path + "': " + EC.message()).str();
return false;
}
- std::string ParseError;
- if (!parse(FileOrErr.get().get(), ParseError)) {
- Error = (Twine("error parsing file '") + Path + "': " + ParseError).str();
+ if (!createInternal(FileOrErr->get(), Error)) {
+ Error = llvm::formatv("error parsing file '{0}': {1}", Path, Error);
return false;
}
}
return true;
}
-
bool SpecialCaseList::createInternal(const MemoryBuffer *MB,
std::string &Error) {
- if (!parse(MB, Error))
+ auto ParsedInput = ParsedSpecialCaseList::parse(*MB);
+ if (!ParsedInput) {
+ Error = llvm::toString(ParsedInput.takeError());
+ return false;
+ }
+ if (auto Err = mergeSections(*std::move(ParsedInput))) {
+ Error = llvm::toString(std::move(Err));
return false;
+ }
return true;
}
+llvm::Error SpecialCaseList::mergeSections(ParsedSpecialCaseList ParsedInput) {
+ bool UseGlobs = !ParsedInput.UseRegexes;
+ for (auto &S : ParsedInput.Sections) {
----------------
bricknerb wrote:
Perhaps replace "S" with "ParsedSection" ?
https://github.com/llvm/llvm-project/pull/116800
More information about the llvm-commits
mailing list