[llvm-branch-commits] [NFC][Support] Use moveInto for bracket parsing in GlobPattern (PR #202849)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jun 9 21:50:26 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-support
Author: Vitaly Buka (vitalybuka)
<details>
<summary>Changes</summary>
Simplify bracket parsing logic by using Expected::moveInto to extract the BitVector.
Assisted-by: Gemini
---
Full diff: https://github.com/llvm/llvm-project/pull/202849.diff
1 Files Affected:
- (modified) llvm/lib/Support/GlobPattern.cpp (+5-5)
``````````diff
diff --git a/llvm/lib/Support/GlobPattern.cpp b/llvm/lib/Support/GlobPattern.cpp
index 1acd25c892d13..6be202fb30f28 100644
--- a/llvm/lib/Support/GlobPattern.cpp
+++ b/llvm/lib/Support/GlobPattern.cpp
@@ -228,11 +228,11 @@ GlobPattern::SubGlobPattern::create(StringRef S) {
errc::invalid_argument);
StringRef Chars = S.substr(I, J - I);
bool Invert = S[I] == '^' || S[I] == '!';
- Expected<BitVector> BVOrErr =
- Invert ? expand(Chars.substr(1), S) : expand(Chars, S);
- if (!BVOrErr)
- return BVOrErr.takeError();
- BitVector BV = std::move(*BVOrErr);
+ if (Invert)
+ Chars = Chars.drop_front();
+ BitVector BV;
+ if (auto Err = expand(Chars, S).moveInto(BV))
+ return Err;
if (Invert)
BV.flip();
Pat.Brackets.push_back(Bracket{J + 1, std::move(BV)});
``````````
</details>
https://github.com/llvm/llvm-project/pull/202849
More information about the llvm-branch-commits
mailing list