[lld] 51fb76f - [lld] Use StringRef::consume_front_insensitive (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 12 22:08:36 PST 2024


Author: Kazu Hirata
Date: 2024-01-12T22:08:26-08:00
New Revision: 51fb76ff1d4a888342c4a406904096b32cc49866

URL: https://github.com/llvm/llvm-project/commit/51fb76ff1d4a888342c4a406904096b32cc49866
DIFF: https://github.com/llvm/llvm-project/commit/51fb76ff1d4a888342c4a406904096b32cc49866.diff

LOG: [lld] Use StringRef::consume_front_insensitive (NFC)

Added: 
    

Modified: 
    lld/COFF/DriverUtils.cpp
    lld/Common/Args.cpp
    lld/MachO/Driver.cpp

Removed: 
    


################################################################################
diff  --git a/lld/COFF/DriverUtils.cpp b/lld/COFF/DriverUtils.cpp
index ab10e2d1ae7425..4678767b6a110c 100644
--- a/lld/COFF/DriverUtils.cpp
+++ b/lld/COFF/DriverUtils.cpp
@@ -310,13 +310,11 @@ void LinkerDriver::parseManifestUAC(StringRef arg) {
     arg = arg.ltrim();
     if (arg.empty())
       return;
-    if (arg.starts_with_insensitive("level=")) {
-      arg = arg.substr(strlen("level="));
+    if (arg.consume_front_insensitive("level=")) {
       std::tie(ctx.config.manifestLevel, arg) = arg.split(" ");
       continue;
     }
-    if (arg.starts_with_insensitive("uiaccess=")) {
-      arg = arg.substr(strlen("uiaccess="));
+    if (arg.consume_front_insensitive("uiaccess=")) {
       std::tie(ctx.config.manifestUIAccess, arg) = arg.split(" ");
       continue;
     }

diff  --git a/lld/Common/Args.cpp b/lld/Common/Args.cpp
index 48c934df3a2c93..67d7babc96fff9 100644
--- a/lld/Common/Args.cpp
+++ b/lld/Common/Args.cpp
@@ -31,8 +31,8 @@ static int64_t getInteger(opt::InputArgList &args, unsigned key,
 
   int64_t v;
   StringRef s = a->getValue();
-  if (base == 16 && (s.starts_with("0x") || s.starts_with("0X")))
-    s = s.drop_front(2);
+  if (base == 16)
+    s.consume_front_insensitive("0x");
   if (to_integer(s, v, base))
     return v;
 

diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 5885a1fae4f343..401459a054394e 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -952,8 +952,7 @@ static std::vector<SectionAlign> parseSectAlign(const opt::InputArgList &args) {
     StringRef segName = arg->getValue(0);
     StringRef sectName = arg->getValue(1);
     StringRef alignStr = arg->getValue(2);
-    if (alignStr.starts_with("0x") || alignStr.starts_with("0X"))
-      alignStr = alignStr.drop_front(2);
+    alignStr.consume_front_insensitive("0x");
     uint32_t align;
     if (alignStr.getAsInteger(16, align)) {
       error("-sectalign: failed to parse '" + StringRef(arg->getValue(2)) +


        


More information about the llvm-commits mailing list