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,
3115
3115
static bool isSmartOwningPtrType (QualType QT) {
3116
3116
QT = QT->getCanonicalTypeUnqualified ();
3117
3117
3118
+ auto isSmartPtrName = [](StringRef Name) {
3119
+ return Name == " unique_ptr" || Name == " shared_ptr" ;
3120
+ };
3121
+
3118
3122
// First try TemplateSpecializationType (for std smart pointers)
3119
3123
if (const auto *TST = QT->getAs <TemplateSpecializationType>()) {
3120
3124
const TemplateDecl *TD = TST->getTemplateName ().getAsTemplateDecl ();
@@ -3129,17 +3133,13 @@ static bool isSmartOwningPtrType(QualType QT) {
3129
3133
if (!isWithinStdNamespace (ND))
3130
3134
return false ;
3131
3135
3132
- StringRef Name = ND->getName ();
3133
- return Name == " unique_ptr" || Name == " shared_ptr" ;
3136
+ return isSmartPtrName (ND->getName ());
3134
3137
}
3135
3138
3136
3139
// Also try RecordType (for custom smart pointer implementations)
3137
3140
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 ()));
3143
3143
}
3144
3144
3145
3145
return false ;
You can’t perform that action at this time.
0 commit comments