[clang-tools-extra] d6ad67d - [clang-tidy] Use StringRef::consume_back (NFC)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 27 22:20:35 PST 2024


Author: Kazu Hirata
Date: 2024-01-27T22:20:24-08:00
New Revision: d6ad67df6bdd1e49f4f57ae8dfa1b05daf081c6e

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

LOG: [clang-tidy] Use StringRef::consume_back (NFC)

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 0a80c996aaaade5..de2a3b51422a5c3 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -62,8 +62,7 @@ class ClangTidyDiagnosticRenderer : public DiagnosticRenderer {
     // appending the check name to the message in ClangTidyContext::diag and
     // using getCustomDiagID.
     std::string CheckNameInMessage = " [" + Error.DiagnosticName + "]";
-    if (Message.ends_with(CheckNameInMessage))
-      Message = Message.substr(0, Message.size() - CheckNameInMessage.size());
+    Message.consume_back(CheckNameInMessage);
 
     auto TidyMessage =
         Loc.isValid()


        


More information about the cfe-commits mailing list