[lld] [llvm] [lld] Initialize SingleStringMatcher::ExactMatch (PR #123138)

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 15 15:38:14 PST 2025


https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/123138

>From 1ab88d1f90dc563b65e0127a865297429e8a75ff Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Wed, 15 Jan 2025 15:21:54 -0800
Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 lld/Common/Strings.cpp | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

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

>From 4e874462c9fcd98199d0a8802176dd72e6ef8205 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Wed, 15 Jan 2025 15:37:32 -0800
Subject: [PATCH 2/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20introduced=20through=20rebase?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4

[skip ci]
---
 llvm/lib/ObjectYAML/ELFYAML.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp
index 7e94d01a971534..83e6cf76dd746f 100644
--- a/llvm/lib/ObjectYAML/ELFYAML.cpp
+++ b/llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -1588,7 +1588,7 @@ static bool isInteger(StringRef Val) {
 
 void MappingTraits<std::unique_ptr<ELFYAML::Chunk>>::mapping(
     IO &IO, std::unique_ptr<ELFYAML::Chunk> &Section) {
-  ELFYAML::ELF_SHT Type;
+  ELFYAML::ELF_SHT Type = ELF::ET_NONE;
   StringRef TypeStr;
   if (IO.outputting()) {
     if (auto *S = dyn_cast<ELFYAML::Section>(Section.get()))

>From 7f5e7019bd876c30dafa9efc76d05450dedf5c12 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Wed, 15 Jan 2025 15:38:04 -0800
Subject: [PATCH 3/3] format

Created using spr 1.3.4
---
 llvm/lib/ObjectYAML/ELFYAML.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp
index 83e6cf76dd746f..7e94d01a971534 100644
--- a/llvm/lib/ObjectYAML/ELFYAML.cpp
+++ b/llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -1588,7 +1588,7 @@ static bool isInteger(StringRef Val) {
 
 void MappingTraits<std::unique_ptr<ELFYAML::Chunk>>::mapping(
     IO &IO, std::unique_ptr<ELFYAML::Chunk> &Section) {
-  ELFYAML::ELF_SHT Type = ELF::ET_NONE;
+  ELFYAML::ELF_SHT Type;
   StringRef TypeStr;
   if (IO.outputting()) {
     if (auto *S = dyn_cast<ELFYAML::Section>(Section.get()))



More information about the llvm-commits mailing list