[lld] [lld] Initialize SingleStringMatcher::ExactMatch (PR #123138)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 15 15:23:00 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lld-coff
@llvm/pr-subscribers-lld
Author: Vitaly Buka (vitalybuka)
<details>
<summary>Changes</summary>
It was not set false in all branches.
---
Full diff: https://github.com/llvm/llvm-project/pull/123138.diff
1 Files Affected:
- (modified) lld/Common/Strings.cpp (+7-5)
``````````diff
diff --git a/lld/Common/Strings.cpp b/lld/Common/Strings.cpp
index 41cbbf36f38cb0..8e1a8ce212878f 100644
--- a/lld/Common/Strings.cpp
+++ b/lld/Common/Strings.cpp
@@ -19,10 +19,13 @@
using namespace llvm;
using namespace lld;
-SingleStringMatcher::SingleStringMatcher(StringRef Pattern) {
- if (Pattern.size() > 2 && Pattern.starts_with("\"") &&
- Pattern.ends_with("\"")) {
- ExactMatch = true;
+static bool isExact(StringRef Pattern) {
+ return Pattern.size() > 2 && Pattern.starts_with("\"") &&
+ Pattern.ends_with("\"");
+}
+
+SingleStringMatcher::SingleStringMatcher(StringRef Pattern) : ExactMatch(isExact(Pattern)) {
+ if (ExactMatch) {
ExactPattern = Pattern.substr(1, Pattern.size() - 2);
} else {
Expected<GlobPattern> Glob = GlobPattern::create(Pattern);
@@ -30,7 +33,6 @@ SingleStringMatcher::SingleStringMatcher(StringRef Pattern) {
error(toString(Glob.takeError()) + ": " + Pattern);
return;
}
- ExactMatch = false;
GlobPatternMatcher = *Glob;
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/123138
More information about the llvm-commits
mailing list