[clang] [Analysis] Avoid creating a temporary instance of std::string (NFC) (PR #151625)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 31 19:46:42 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/151625
hasName takes StringRef, so we don't need to create a temporary
instance of std::string.
>From 7840655c7f8db70b5105402598c154eb6f44966d Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 31 Jul 2025 15:25:43 -0700
Subject: [PATCH] [Analysis] Avoid creating a temporary instance of std::string
(NFC)
hasName takes StringRef, so we don't need to create a temporary
instance of std::string.
---
clang/lib/Analysis/RetainSummaryManager.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/clang/lib/Analysis/RetainSummaryManager.cpp b/clang/lib/Analysis/RetainSummaryManager.cpp
index 987f894a2918f..688efe40875d2 100644
--- a/clang/lib/Analysis/RetainSummaryManager.cpp
+++ b/clang/lib/Analysis/RetainSummaryManager.cpp
@@ -147,8 +147,7 @@ static bool isSubclass(const Decl *D,
static bool isExactClass(const Decl *D, StringRef ClassName) {
using namespace ast_matchers;
- DeclarationMatcher sameClassM =
- cxxRecordDecl(hasName(std::string(ClassName)));
+ DeclarationMatcher sameClassM = cxxRecordDecl(hasName(ClassName));
return !(match(sameClassM, *D, D->getASTContext()).empty());
}
More information about the cfe-commits
mailing list