Skip to content

Commit 05674b2

Browse files
[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.
1 parent 782c066 commit 05674b2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ std::string LLVMHeaderGuardCheck::getHeaderGuard(StringRef Filename,
4040
// Unlike LLVM svn, LLVM git monorepo is named llvm-project, so we replace
4141
// "/llvm-project/" with the canonical "/llvm/".
4242
const static StringRef LLVMProject = "/llvm-project/";
43-
size_t PosLLVMProject = Guard.rfind(std::string(LLVMProject));
43+
size_t PosLLVMProject = Guard.rfind(LLVMProject);
4444
if (PosLLVMProject != StringRef::npos)
4545
Guard = Guard.replace(PosLLVMProject, LLVMProject.size(), "/llvm/");
4646

0 commit comments

Comments
 (0)