Skip to content

[lld] Initialize SingleStringMatcher::ExactMatch #123138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

vitalybuka
Copy link
Collaborator

It was not set false in all branches.

Created using spr 1.3.4
@llvmbot
Copy link
Member

llvmbot commented Jan 15, 2025

@llvm/pr-subscribers-objectyaml
@llvm/pr-subscribers-lld-wasm
@llvm/pr-subscribers-lld-macho
@llvm/pr-subscribers-lld-coff

@llvm/pr-subscribers-lld

Author: Vitaly Buka (vitalybuka)

Changes

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 --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;
   }
 }

@llvmbot
Copy link
Member

llvmbot commented Jan 15, 2025

@llvm/pr-subscribers-lld-elf

Author: Vitaly Buka (vitalybuka)

Changes

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 --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;
   }
 }

@vitalybuka vitalybuka requested review from MaskRay and fmayer January 15, 2025 23:23
Copy link

github-actions bot commented Jan 15, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
Created using spr 1.3.4
@vitalybuka vitalybuka merged commit 42662c2 into main Jan 16, 2025
6 of 7 checks passed
@vitalybuka vitalybuka deleted the users/vitalybuka/spr/lld-initialize-singlestringmatcherexactmatch branch January 16, 2025 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants