Skip to content

Deallocation: Adds memory deallocation analysis functions#1052

Open
keremsahn wants to merge 1 commit into
compiler-research:mainfrom
keremsahn:dealloc-detect
Open

Deallocation: Adds memory deallocation analysis functions#1052
keremsahn wants to merge 1 commit into
compiler-research:mainfrom
keremsahn:dealloc-detect

Conversation

@keremsahn

Copy link
Copy Markdown
Contributor

FIXME 's and some other cases will be handled after I open issues.

@keremsahn

Copy link
Copy Markdown
Contributor Author

@keremsahn keremsahn force-pushed the dealloc-detect branch 2 times, most recently from db84730 to 9c871a2 Compare July 6, 2026 23:10
@keremsahn keremsahn changed the title Adds memory allocation analysis functions Deallocation: Adds memory deallocation analysis functions Jul 6, 2026
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.60305% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.73%. Comparing base (91a0c1e) to head (ba114e4).

Files with missing lines Patch % Lines
lib/CppInterOp/CppInterOp.cpp 91.60% 11 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1052      +/-   ##
==========================================
+ Coverage   86.62%   86.73%   +0.10%     
==========================================
  Files          23       23              
  Lines        5946     6077     +131     
==========================================
+ Hits         5151     5271     +120     
- Misses        795      806      +11     
Files with missing lines Coverage Δ
include/CppInterOp/CppInterOpTypes.h 96.90% <ø> (ø)
lib/CppInterOp/CppInterOp.cpp 89.22% <91.60%> (+0.10%) ⬆️
Files with missing lines Coverage Δ
include/CppInterOp/CppInterOpTypes.h 96.90% <ø> (ø)
lib/CppInterOp/CppInterOp.cpp 89.22% <91.60%> (+0.10%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

struct DeallocationTraverser : RecursiveASTVisitor<DeallocationTraverser> {
std::unordered_map<const clang::VarDecl*, const clang::ParmVarDecl*> aliasMap;
std::set<const clang::ParmVarDecl*> overwritenParms;
std::vector<DeallocType>& VPP;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "Cpp::DeallocType" is directly included [misc-include-cleaner]

nParms;
                      ^

std::unordered_map<const clang::VarDecl*, const clang::ParmVarDecl*> aliasMap;
std::set<const clang::ParmVarDecl*> overwritenParms;
std::vector<DeallocType>& VPP;
DeallocationTraverser(std::vector<DeallocType>& v) : VPP(v) {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: member 'VPP' of type 'std::vector &' is a reference [cppcoreguidelines-avoid-const-or-ref-data-members]

>& VPP;
   ^


bool TraverseDecl(clang::Decl* D) {
if (D && llvm::isa<clang::TagDecl>(D))
return true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: isa_and_nonnull<> is preferred over an explicit test for null followed by calling isa<> [llvm-prefer-isa-or-dyn-cast-in-conditionals]

Suggested change
return true;
l* D) {
cl>(D))isa_and_nonnullm::isa<clang::TagDecl>(D)

updateVPP(PVR->getFunctionScopeIndex(), DeallocType::Free);
}

bool shouldVisitLambdaBody() const { return false; }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: method 'shouldVisitLambdaBody' can be made static [readability-convert-member-functions-to-static]

Suggested change
bool shouldVisitLambdaBody() const { return false; }
);static

return;
}
DeallocationTraverser Traverser(valPerParam);
Traverser.TraverseStmt(const_cast<CompoundStmt*>(CmpStmt));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use const_cast to remove const qualifier [cppcoreguidelines-pro-type-const-cast]

Param);
                                 ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant