[clang-tools-extra] 05674b2 - [clang-tidy] Use std:::string::find with std::string_view (NFC) (#141188)
via cfe-commits
cfe-commits at lists.llvm.org
Thu May 22 23:50:58 PDT 2025
Author: Kazu Hirata
Date: 2025-05-22T23:50:55-07:00
New Revision: 05674b21fed51a940b93e09b38d1833010f3f694
URL: https://github.com/llvm/llvm-project/commit/05674b21fed51a940b93e09b38d1833010f3f694
DIFF: https://github.com/llvm/llvm-project/commit/05674b21fed51a940b93e09b38d1833010f3f694.diff
LOG: [clang-tidy] Use std:::string::find with std::string_view (NFC) (#141188)
std::string::rfind accepts anything that can be converted to
std::string_view starting in C++17. Since StringRef can be converted
to std::string_view, we do not need to create a temporary instance of
std::string here.
Added:
Modified:
clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp b/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
index ba89070be59cc..3ea235b1fed7f 100644
--- a/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
@@ -40,7 +40,7 @@ std::string LLVMHeaderGuardCheck::getHeaderGuard(StringRef Filename,
// Unlike LLVM svn, LLVM git monorepo is named llvm-project, so we replace
// "/llvm-project/" with the canonical "/llvm/".
const static StringRef LLVMProject = "/llvm-project/";
- size_t PosLLVMProject = Guard.rfind(std::string(LLVMProject));
+ size_t PosLLVMProject = Guard.rfind(LLVMProject);
if (PosLLVMProject != StringRef::npos)
Guard = Guard.replace(PosLLVMProject, LLVMProject.size(), "/llvm/");
More information about the cfe-commits
mailing list