Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

hasName takes StringRef, so we don't need to create a temporary
instance of std::string.

hasName takes StringRef, so we don't need to create a temporary
instance of std::string.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:analysis labels Aug 1, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 1, 2025

@llvm/pr-subscribers-clang-analysis

@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)

Changes

hasName takes StringRef, so we don't need to create a temporary
instance of std::string.


Full diff: https://github.com/llvm/llvm-project/pull/151625.diff

1 Files Affected:

  • (modified) clang/lib/Analysis/RetainSummaryManager.cpp (+1-2)
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());
 }
 

@kazutakahirata kazutakahirata merged commit 8365ba6 into llvm:main Aug 1, 2025
12 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20250731_hasName branch August 1, 2025 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:analysis clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants