[llvm] [NFC][SpecialCaseList] Generalize "#!special-case-list-v" parsing (PR #162350)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 7 12:37:11 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-support
Author: Vitaly Buka (vitalybuka)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/162350.diff
1 Files Affected:
- (modified) llvm/lib/Support/SpecialCaseList.cpp (+16-7)
``````````diff
diff --git a/llvm/lib/Support/SpecialCaseList.cpp b/llvm/lib/Support/SpecialCaseList.cpp
index 4b038850b62ca..c0bfeb4020872 100644
--- a/llvm/lib/Support/SpecialCaseList.cpp
+++ b/llvm/lib/Support/SpecialCaseList.cpp
@@ -15,9 +15,12 @@
#include "llvm/Support/SpecialCaseList.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/Support/LineIterator.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/VirtualFileSystem.h"
+#include <limits>
#include <stdio.h>
#include <string>
#include <system_error>
@@ -147,19 +150,25 @@ SpecialCaseList::addSection(StringRef SectionStr, unsigned FileNo,
bool SpecialCaseList::parse(unsigned FileIdx, const MemoryBuffer *MB,
std::string &Error) {
+ unsigned long long Version = std::numeric_limits<unsigned long long>::max();
+
+ StringRef Header = MB->getBuffer();
+ if (Header.consume_front("#!special-case-list-v"))
+ consumeUnsignedInteger(Header, 10, Version);
+
+ // 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 = Version > 1;
+
Section *CurrentSection;
if (auto Err = addSection("*", FileIdx, 1).moveInto(CurrentSection)) {
Error = toString(std::move(Err));
return false;
}
- // 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=*/'#');
!LineIt.is_at_eof(); LineIt++) {
unsigned LineNo = LineIt.line_number();
``````````
</details>
https://github.com/llvm/llvm-project/pull/162350
More information about the llvm-commits
mailing list