Skip to content

Commit 7b26915

Browse files
committed
[analyzer] MallocChecker: Address minor style and review comments
- Applied minor style fixes and small improvements per review feedback.
1 parent 333e5ba commit 7b26915

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
#include "clang/AST/DeclTemplate.h"
5353
#include "clang/AST/Expr.h"
5454
#include "clang/AST/ExprCXX.h"
55-
5655
#include "clang/AST/ParentMap.h"
5756
#include "clang/ASTMatchers/ASTMatchFinder.h"
5857
#include "clang/ASTMatchers/ASTMatchers.h"
@@ -1125,11 +1124,9 @@ class EscapeTrackedCallback final : public SymbolVisitor {
11251124
for (const MemRegion *R : Roots) {
11261125
State->scanReachableSymbols(loc::MemRegionVal(R), Visitor);
11271126
}
1128-
return Visitor.getState();
1127+
return Visitor.State;
11291128
}
11301129

1131-
ProgramStateRef getState() const { return State; }
1132-
11331130
bool VisitSymbol(SymbolRef Sym) override {
11341131
if (const RefState *RS = State->get<RegionState>(Sym)) {
11351132
if (RS->isAllocated() || RS->isAllocatedOfSizeZero()) {
@@ -3111,17 +3108,13 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper,
31113108
C.addTransition(state->set<RegionState>(RS), N);
31123109
}
31133110

3114-
// Use isWithinStdNamespace from CheckerHelpers.h instead of custom
3115-
// implementation
3116-
31173111
// Allowlist of owning smart pointers we want to recognize.
31183112
// Start with unique_ptr and shared_ptr. (intentionally exclude weak_ptr)
31193113
static bool isSmartOwningPtrType(QualType QT) {
31203114
QT = QT->getCanonicalTypeUnqualified();
31213115

31223116
// 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>()) {
31253118
const TemplateDecl *TD = TST->getTemplateName().getAsTemplateDecl();
31263119
if (!TD)
31273120
return false;
@@ -3139,8 +3132,7 @@ static bool isSmartOwningPtrType(QualType QT) {
31393132
}
31403133

31413134
// Also try RecordType (for custom smart pointer implementations)
3142-
const auto *RD = QT->getAsCXXRecordDecl();
3143-
if (RD) {
3135+
if (const auto *RD = QT->getAsCXXRecordDecl()) {
31443136
StringRef Name = RD->getName();
31453137
if (Name == "unique_ptr" || Name == "shared_ptr") {
31463138
// Accept any custom unique_ptr or shared_ptr implementation

0 commit comments

Comments
 (0)