[clang] [libclang/python] Type-annotate SourceLocation and SourceRange (PR #180193)
Jannick Kremer via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 6 06:22:52 PST 2026
================
@@ -278,31 +278,33 @@ class SourceLocation(Structure):
"""
_fields_ = [("ptr_data", c_void_p * 2), ("int_data", c_uint)]
- _data = None
+ _data: tuple[File | None, int, int, int] | None = None
- def _get_instantiation(self):
+ def _get_instantiation(self) -> tuple[File | None, int, int, int]:
if self._data is None:
f, l, c, o = c_object_p(), c_uint(), c_uint(), c_uint()
conf.lib.clang_getInstantiationLocation(
self, byref(f), byref(l), byref(c), byref(o)
)
if f:
- f = File(f)
+ file = File(f)
else:
- f = None
- self._data = (f, int(l.value), int(c.value), int(o.value))
+ file = None
+ self._data = (file, int(l.value), int(c.value), int(o.value))
----------------
DeinAlptraum wrote:
The renaming here is necessary because the `f` variable is already assigned a `c_object_p` type a few lines above, so it cannot be reused here with a different type.
https://github.com/llvm/llvm-project/pull/180193
More information about the cfe-commits
mailing list