-
Notifications
You must be signed in to change notification settings - Fork 31
Destroy the interpreters when they are owned. #610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #610 +/- ##
==========================================
+ Coverage 77.48% 77.58% +0.09%
==========================================
Files 9 9
Lines 3713 3734 +21
==========================================
+ Hits 2877 2897 +20
- Misses 836 837 +1
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
static llvm::SmallVector<InterpreterInfo, 8> sInterpreters; | ||
|
||
// std::deque avoids relocations and calling the dtor of InterpreterInfo. | ||
static llvm::ManagedStatic<std::deque<InterpreterInfo>> sInterpreters; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'sInterpreters' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
static llvm::ManagedStatic<std::deque<InterpreterInfo>> sInterpreters;
^
lib/CppInterOp/CppInterOp.cpp
Outdated
assert(sInterpreters.empty() && "sInterpreter already in use!"); | ||
sInterpreters.push_back( | ||
assert(sInterpreters->empty() && "sInterpreter already in use!"); | ||
sInterpreters->push_back( | ||
{static_cast<compat::Interpreter*>(I), /*isOwned=*/false}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: argument name 'isOwned' in comment does not match parameter name 'O' [bugprone-argument-comment]
{static_cast<compat::Interpreter*>(I), /*isOwned=*/false});
^
Additional context
lib/CppInterOp/CppInterOp.cpp:88: 'O' declared here
InterpreterInfo(compat::Interpreter* I, bool O)
^
lib/CppInterOp/CppInterOp.cpp
Outdated
assert(sInterpreters.empty() && "sInterpreter already in use!"); | ||
sInterpreters.push_back( | ||
assert(sInterpreters->empty() && "sInterpreter already in use!"); | ||
sInterpreters->push_back( | ||
{static_cast<compat::Interpreter*>(I), /*isOwned=*/false}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: use emplace_back instead of push_back [modernize-use-emplace]
{static_cast<compat::Interpreter*>(I), /*isOwned=*/false}); | |
sInterpreters->emplace_back(static_cast<compat::Interpreter*>(I), /*isOwned=*/false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe worth looking at this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
lib/CppInterOp/CppInterOp.cpp
Outdated
assert(sInterpreters.empty() && "sInterpreter already in use!"); | ||
sInterpreters.push_back( | ||
assert(sInterpreters->empty() && "sInterpreter already in use!"); | ||
sInterpreters->push_back( | ||
{static_cast<compat::Interpreter*>(I), /*isOwned=*/false}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe worth looking at this.
This should fix a longstanding issue with resource deallocation in CppInterOp.
This should fix a longstanding issue with resource deallocation in CppInterOp.