Destroy the interpreters when they are owned.#610
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:
|
| 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.
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;
^| 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.
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)
^| 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.
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.
Maybe worth looking at this.
| 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.
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.