Author: Marek Kurdej
Date: 2022-02-02T14:36:00+01:00
New Revision: 10243d0dfd36b0fb912276b2686a038b952e03c8

URL: 
https://github.com/llvm/llvm-project/commit/10243d0dfd36b0fb912276b2686a038b952e03c8
DIFF: 
https://github.com/llvm/llvm-project/commit/10243d0dfd36b0fb912276b2686a038b952e03c8.diff

LOG: [clang-format] Simplify use of StringRef::substr(). NFC.

Added: 
    

Modified: 
    clang/lib/Format/BreakableToken.cpp
    clang/lib/Format/FormatTokenLexer.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Format/BreakableToken.cpp 
b/clang/lib/Format/BreakableToken.cpp
index f68d802c1f95f..417fada35119f 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -417,7 +417,7 @@ BreakableBlockComment::BreakableBlockComment(
     if (!Content[i].empty() && i + 1 != e && Decoration.startswith(Content[i]))
       continue;
     while (!Content[i].startswith(Decoration))
-      Decoration = Decoration.substr(0, Decoration.size() - 1);
+      Decoration = Decoration.drop_back(1);
   }
 
   LastLineNeedsDecoration = true;

diff  --git a/clang/lib/Format/FormatTokenLexer.cpp 
b/clang/lib/Format/FormatTokenLexer.cpp
index c9166f4b17aab..638b490773e71 100644
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -621,9 +621,9 @@ void 
FormatTokenLexer::handleCSharpVerbatimAndInterpolatedStrings() {
   if (LastBreak != StringRef::npos) {
     CSharpStringLiteral->IsMultiline = true;
     unsigned StartColumn = 0;
-    CSharpStringLiteral->LastLineColumnWidth = encoding::columnWidthWithTabs(
-        LiteralText.substr(LastBreak + 1, LiteralText.size()), StartColumn,
-        Style.TabWidth, Encoding);
+    CSharpStringLiteral->LastLineColumnWidth =
+        encoding::columnWidthWithTabs(LiteralText.substr(LastBreak + 1),
+                                      StartColumn, Style.TabWidth, Encoding);
   }
 
   SourceLocation loc = Offset < Lex->getBuffer().end()
@@ -688,9 +688,9 @@ void FormatTokenLexer::handleTemplateStrings() {
   if (LastBreak != StringRef::npos) {
     BacktickToken->IsMultiline = true;
     unsigned StartColumn = 0; // The template tail spans the entire line.
-    BacktickToken->LastLineColumnWidth = encoding::columnWidthWithTabs(
-        LiteralText.substr(LastBreak + 1, LiteralText.size()), StartColumn,
-        Style.TabWidth, Encoding);
+    BacktickToken->LastLineColumnWidth =
+        encoding::columnWidthWithTabs(LiteralText.substr(LastBreak + 1),
+                                      StartColumn, Style.TabWidth, Encoding);
   }
 
   SourceLocation loc = Offset < Lex->getBuffer().end()


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to