[llvm] 57f443c - [SimplifyLibCalls][NFC] Use StringRef::back instead explicit indexing.

Dávid Bolvanský via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 22 06:03:02 PDT 2021


Author: Dawid Jurczak
Date: 2021-04-22T15:02:47+02:00
New Revision: 57f443c34866de827bcc5223c93367d93b2c18c8

URL: https://github.com/llvm/llvm-project/commit/57f443c34866de827bcc5223c93367d93b2c18c8
DIFF: https://github.com/llvm/llvm-project/commit/57f443c34866de827bcc5223c93367d93b2c18c8.diff

LOG: [SimplifyLibCalls][NFC] Use StringRef::back instead explicit indexing.

Split off from D100724.

Reviewed By: xbolva00

Differential Revision: https://reviews.llvm.org/D101032

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index ab181be20964d..4a817f90d32fb 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -2388,7 +2388,7 @@ Value *LibCallSimplifier::optimizePrintFString(CallInst *CI, IRBuilderBase &B) {
   }
 
   // printf("foo\n") --> puts("foo")
-  if (FormatStr[FormatStr.size() - 1] == '\n' &&
+  if (FormatStr.back() == '\n' &&
       FormatStr.find('%') == StringRef::npos) { // No format characters.
     // Create a string literal with no \n on it.  We expect the constant merge
     // pass to be run after this pass, to merge duplicate strings.


        


More information about the llvm-commits mailing list