52
52
#include " clang/AST/DeclTemplate.h"
53
53
#include " clang/AST/Expr.h"
54
54
#include " clang/AST/ExprCXX.h"
55
-
56
55
#include " clang/AST/ParentMap.h"
57
56
#include " clang/ASTMatchers/ASTMatchFinder.h"
58
57
#include " clang/ASTMatchers/ASTMatchers.h"
@@ -1125,11 +1124,9 @@ class EscapeTrackedCallback final : public SymbolVisitor {
1125
1124
for (const MemRegion *R : Roots) {
1126
1125
State->scanReachableSymbols (loc::MemRegionVal (R), Visitor);
1127
1126
}
1128
- return Visitor.getState () ;
1127
+ return Visitor.State ;
1129
1128
}
1130
1129
1131
- ProgramStateRef getState () const { return State; }
1132
-
1133
1130
bool VisitSymbol (SymbolRef Sym) override {
1134
1131
if (const RefState *RS = State->get <RegionState>(Sym)) {
1135
1132
if (RS->isAllocated () || RS->isAllocatedOfSizeZero ()) {
@@ -3111,17 +3108,13 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper,
3111
3108
C.addTransition (state->set <RegionState>(RS), N);
3112
3109
}
3113
3110
3114
- // Use isWithinStdNamespace from CheckerHelpers.h instead of custom
3115
- // implementation
3116
-
3117
3111
// Allowlist of owning smart pointers we want to recognize.
3118
3112
// Start with unique_ptr and shared_ptr. (intentionally exclude weak_ptr)
3119
3113
static bool isSmartOwningPtrType (QualType QT) {
3120
3114
QT = QT->getCanonicalTypeUnqualified ();
3121
3115
3122
3116
// First try TemplateSpecializationType (for std smart pointers)
3123
- const auto *TST = QT->getAs <TemplateSpecializationType>();
3124
- if (TST) {
3117
+ if (const auto *TST = QT->getAs <TemplateSpecializationType>()) {
3125
3118
const TemplateDecl *TD = TST->getTemplateName ().getAsTemplateDecl ();
3126
3119
if (!TD)
3127
3120
return false ;
@@ -3139,8 +3132,7 @@ static bool isSmartOwningPtrType(QualType QT) {
3139
3132
}
3140
3133
3141
3134
// Also try RecordType (for custom smart pointer implementations)
3142
- const auto *RD = QT->getAsCXXRecordDecl ();
3143
- if (RD) {
3135
+ if (const auto *RD = QT->getAsCXXRecordDecl ()) {
3144
3136
StringRef Name = RD->getName ();
3145
3137
if (Name == " unique_ptr" || Name == " shared_ptr" ) {
3146
3138
// Accept any custom unique_ptr or shared_ptr implementation
0 commit comments