[clang] [libclang/python] Fold CCRStructure into CodeCompletionResults (PR #224678)

Jannick Kremer via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 6 16:53:56 PDT 2026


================
@@ -3216,38 +3216,20 @@ def __getitem__(self, key: int) -> CodeCompletionResult:
         return self.results[key]
 
 
-class CodeCompletionResults(ClangObject):
-    def __init__(self, ptr: _Pointer[CCRStructure]):
-        assert isinstance(ptr, POINTER(CCRStructure)) and ptr
-        self.ptr = self._as_parameter_ = ptr
----------------
DeinAlptraum wrote:

> I don't have ideas either what might have happened with a pointer to an object that we ourselves are responsible to free (the right term for that is ownership, but I'm not sure if you are familiar with it).

That in itself is not necessarily a problem, or at least it was wired up correctly: the Python garbage collector calls a class's `__del__` method once it can be cleaned up, which in the case of `CodeCompletionResults` just calls the cleanup function from the C-library. 

> Just in case, I don't have objections over the changes you ended up with. I want to make sure that we have the best shared understanding of the old code.

I thought I'd understood the code, but then my first fix didn't work so now I'm not entirely.

https://github.com/llvm/llvm-project/pull/224678


More information about the cfe-commits mailing list