[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


================
@@ -143,63 +177,55 @@ SpecialCaseList::addSection(StringRef SectionStr, unsigned LineNo,
   return &Section;
 }
 
-bool SpecialCaseList::parse(const MemoryBuffer *MB, std::string &Error) {
-  Section *CurrentSection;
-  if (auto Err = addSection("*", 1).moveInto(CurrentSection)) {
-    Error = toString(std::move(Err));
-    return false;
-  }
-
+llvm::Expected<ParsedSpecialCaseList>
+ParsedSpecialCaseList::parse(const MemoryBuffer &MB) {
+  ParsedSpecialCaseList Result;
   // In https://reviews.llvm.org/D154014 we added glob support and planned to
   // remove regex support in patterns. We temporarily support the original
   // behavior using regexes if "#!special-case-list-v1" is the first line of the
   // file. For more details, see
   // https://discourse.llvm.org/t/use-glob-instead-of-regex-for-specialcaselists/71666
-  bool UseGlobs = !MB->getBuffer().starts_with("#!special-case-list-v1\n");
-
-  for (line_iterator LineIt(*MB, /*SkipBlanks=*/true, /*CommentMarker=*/'#');
+  Result.UseRegexes = MB.getBuffer().starts_with("#!special-case-list-v1\n");
+  for (line_iterator LineIt(MB, /*SkipBlanks=*/true, /*CommentMarker=*/'#');
        !LineIt.is_at_eof(); LineIt++) {
-    unsigned LineNo = LineIt.line_number();
+    std::size_t LineNo = LineIt.line_number();
----------------
bricknerb wrote:

Ditto move it to a separate PR.

https://github.com/llvm/llvm-project/pull/116800


More information about the llvm-commits mailing list