File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
clang/lib/StaticAnalyzer/Checkers Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -3115,6 +3115,10 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper,
31153115static bool isSmartOwningPtrType (QualType QT) {
31163116 QT = QT->getCanonicalTypeUnqualified ();
31173117
3118+ auto isSmartPtrName = [](StringRef Name) {
3119+ return Name == " unique_ptr" || Name == " shared_ptr" ;
3120+ };
3121+
31183122 // First try TemplateSpecializationType (for std smart pointers)
31193123 if (const auto *TST = QT->getAs <TemplateSpecializationType>()) {
31203124 const TemplateDecl *TD = TST->getTemplateName ().getAsTemplateDecl ();
@@ -3129,17 +3133,13 @@ static bool isSmartOwningPtrType(QualType QT) {
31293133 if (!isWithinStdNamespace (ND))
31303134 return false ;
31313135
3132- StringRef Name = ND->getName ();
3133- return Name == " unique_ptr" || Name == " shared_ptr" ;
3136+ return isSmartPtrName (ND->getName ());
31343137 }
31353138
31363139 // Also try RecordType (for custom smart pointer implementations)
31373140 if (const auto *RD = QT->getAsCXXRecordDecl ()) {
3138- StringRef Name = RD->getName ();
3139- if (Name == " unique_ptr" || Name == " shared_ptr" ) {
3140- // Accept any custom unique_ptr or shared_ptr implementation
3141- return true ;
3142- }
3141+ // Accept any custom unique_ptr or shared_ptr implementation
3142+ return (isSmartPtrName (RD->getName ()));
31433143 }
31443144
31453145 return false ;
You can’t perform that action at this time.
0 commit comments