[llvm] 90e9c6e - [llvm] Use StringRef::consume_front (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 4 14:57:38 PST 2024


Author: Kazu Hirata
Date: 2024-02-04T14:57:25-08:00
New Revision: 90e9c6e36e8b928240dfd61c2dfd30cf26108c07

URL: https://github.com/llvm/llvm-project/commit/90e9c6e36e8b928240dfd61c2dfd30cf26108c07
DIFF: https://github.com/llvm/llvm-project/commit/90e9c6e36e8b928240dfd61c2dfd30cf26108c07.diff

LOG: [llvm] Use StringRef::consume_front (NFC)

Added: 
    

Modified: 
    llvm/lib/Object/COFFModuleDefinition.cpp
    llvm/lib/Passes/StandardInstrumentations.cpp
    llvm/lib/Support/FormatVariadic.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Object/COFFModuleDefinition.cpp b/llvm/lib/Object/COFFModuleDefinition.cpp
index 648f01f823d00..35e6ab837b2ab 100644
--- a/llvm/lib/Object/COFFModuleDefinition.cpp
+++ b/llvm/lib/Object/COFFModuleDefinition.cpp
@@ -97,10 +97,8 @@ class Lexer {
     }
     case '=':
       Buf = Buf.drop_front();
-      if (Buf.starts_with("=")) {
-        Buf = Buf.drop_front();
+      if (Buf.consume_front("="))
         return Token(EqualEqual, "==");
-      }
       return Token(Equal, "=");
     case ',':
       Buf = Buf.drop_front();

diff  --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp
index aea8acebcb830..697988b3fc7c0 100644
--- a/llvm/lib/Passes/StandardInstrumentations.cpp
+++ b/llvm/lib/Passes/StandardInstrumentations.cpp
@@ -1816,8 +1816,7 @@ std::string DotCfgDiffNode::getBodyContent() const {
     for (unsigned I = 0; I < 2; ++I) {
       SR[I] = Data[I]->getBody();
       // drop initial '\n' if present
-      if (SR[I][0] == '\n')
-        SR[I] = SR[I].drop_front();
+      SR[I].consume_front("\n");
       // drop predecessors as they can be big and are redundant
       SR[I] = SR[I].drop_until([](char C) { return C == '\n'; }).drop_front();
     }

diff  --git a/llvm/lib/Support/FormatVariadic.cpp b/llvm/lib/Support/FormatVariadic.cpp
index 7bbc80e14c9f7..91b4c38ade4fa 100644
--- a/llvm/lib/Support/FormatVariadic.cpp
+++ b/llvm/lib/Support/FormatVariadic.cpp
@@ -77,8 +77,8 @@ formatv_object_base::parseReplacementItem(StringRef Spec) {
       assert(false && "Invalid replacement field layout specification!");
   }
   RepString = RepString.trim();
-  if (!RepString.empty() && RepString.front() == ':') {
-    Options = RepString.drop_front().trim();
+  if (RepString.consume_front(":")) {
+    Options = RepString.trim();
     RepString = StringRef();
   }
   RepString = RepString.trim();


        


More information about the llvm-commits mailing list