[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-01-14 Thread Jannick Kremer via cfe-commits
@@ -67,89 +67,690 @@ import clang.enumerations import os -import sys - -if sys.version_info[0] == 3: -# Python 3 strings are unicode, translate them to/from utf8 for C-interop. -class c_interop_string(c_char_p): -def __init__(self, p=None): -if p is

[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-01-14 Thread Jannick Kremer via cfe-commits
@@ -67,89 +67,690 @@ import clang.enumerations import os -import sys - -if sys.version_info[0] == 3: -# Python 3 strings are unicode, translate them to/from utf8 for C-interop. -class c_interop_string(c_char_p): -def __init__(self, p=None): -if p is

[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-01-14 Thread Jannick Kremer via cfe-commits
@@ -642,51 +1259,29 @@ def register(value, name): ### Cursor Kinds ### -class BaseEnumeration(object): -""" -Common base class for named enumerations held in sync with Index.h values. +TEnum = TypeVar("TEnum", bound="BaseEnumeration") -Subclasses must define the

[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-01-14 Thread Jannick Kremer via cfe-commits
@@ -642,51 +1259,29 @@ def register(value, name): ### Cursor Kinds ### -class BaseEnumeration(object): -""" -Common base class for named enumerations held in sync with Index.h values. +TEnum = TypeVar("TEnum", bound="BaseEnumeration") -Subclasses must define the

[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-01-14 Thread Jannick Kremer via cfe-commits
@@ -3968,7 +4500,7 @@ def function_exists(self, name): return True -def register_enumerations(): +def register_enumerations() -> None: DeinAlptraum wrote: This implementation dynamically adds the TokenKind variants, which means it also suffers from

[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-01-14 Thread Jannick Kremer via cfe-commits
@@ -232,13 +840,16 @@ class _CXString(Structure): _fields_ = [("spelling", c_char_p), ("free", c_int)] -def __del__(self): +def __del__(self) -> None: conf.lib.clang_disposeString(self) @staticmethod -def from_result(res, fn=None, args=None): +

[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-01-14 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/78114 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-01-14 Thread Jannick Kremer via cfe-commits
@@ -67,89 +67,690 @@ import clang.enumerations import os -import sys - -if sys.version_info[0] == 3: -# Python 3 strings are unicode, translate them to/from utf8 for C-interop. -class c_interop_string(c_char_p): -def __init__(self, p=None): -if p is

[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-01-14 Thread Jannick Kremer via cfe-commits
@@ -67,89 +67,690 @@ import clang.enumerations import os -import sys - -if sys.version_info[0] == 3: -# Python 3 strings are unicode, translate them to/from utf8 for C-interop. -class c_interop_string(c_char_p): -def __init__(self, p=None): -if p is

[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-01-14 Thread Jannick Kremer via cfe-commits
@@ -2341,30 +2830,32 @@ class Type(Structure): _fields_ = [("_kind_id", c_int), ("data", c_void_p * 2)] +_tu: TranslationUnit + @property -def kind(self): +def kind(self) -> TypeKind: """Return the kind of this type.""" return TypeKind.f

[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-01-14 Thread Jannick Kremer via cfe-commits
@@ -67,89 +67,690 @@ import clang.enumerations import os -import sys - -if sys.version_info[0] == 3: -# Python 3 strings are unicode, translate them to/from utf8 for C-interop. -class c_interop_string(c_char_p): -def __init__(self, p=None): -if p is

[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-01-14 Thread Jannick Kremer via cfe-commits
@@ -1722,23 +2300,23 @@ def location(self): return self._loc @property -def linkage(self): +def linkage(self) -> LinkageKind: """Return the linkage of this cursor.""" if not hasattr(self, "_linkage"): self._linkage = conf.lib.

[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-01-14 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/78114 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-01-14 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: @AaronBallman could you review this or recommend reviewers? I didn't see any category in `clang/CodeOwners.rst` that seems to cover the bindings. https://github.com/llvm/llvm-project/pull/78114 ___ cfe-commits mailing list cfe-comm

[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-01-15 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum converted_to_draft https://github.com/llvm/llvm-project/pull/78114 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-01-15 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: I was just made aware of [some](https://github.com/llvm/llvm-project/pull/77219) [changes](https://github.com/llvm/llvm-project/pull/77228) by @linux4life798 that seem reasonable to merge before this, so I've returned this to draft status for now. Sorry for the confusion.

[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-07-01 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: \*Ping* @boomanaiden154 @linux4life798 a review/feedback would be appreciated! https://github.com/llvm/llvm-project/pull/95608 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/

[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-07-01 Thread Jannick Kremer via cfe-commits
@@ -10,26 +10,6 @@ class TestTokenKind(unittest.TestCase): -def test_constructor(self): DeinAlptraum wrote: thNot really: - `test_constructor`: this tests the ability to add enum variants "on the fly", which is not possible with the Python stdlib's `Enu

[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-07-01 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/95608 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-07-01 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/95608 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-07-01 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/95608 >From 35bfcfbc69ee812c59350440b7b15c5e23ad1307 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Fri, 14 Jun 2024 22:12:09 +0100 Subject: [PATCH 1/3] [libclang/python] Refactor enum usage Use Python's bui

[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-07-01 Thread Jannick Kremer via cfe-commits
@@ -10,26 +10,6 @@ class TestTokenKind(unittest.TestCase): -def test_constructor(self): DeinAlptraum wrote: So the existing "custom" enum implementation included a sort of constructor, as we see in this test, that takes a number and name and then adds t

[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-07-01 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/95608 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-07-01 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/95608 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-07-04 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: @Endilll do you think this needs a second review? If not, could you merge this? Since I don't have commit access https://github.com/llvm/llvm-project/pull/95608 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.l

[clang] [libclang/python] Fix bug in `SourceRange.__contains__`, add tests (PR #101802)

2024-08-09 Thread Jannick Kremer via cfe-commits
@@ -386,6 +386,10 @@ def __contains__(self, other): # same file, in between lines if self.start.line < other.line < self.end.line: return True +# between columns in one-liner range +elif self.start.line == other.line == self.end.line:

[clang] [libclang/python] Fix bug in `SourceRange.__contains__`, add tests (PR #101802)

2024-08-09 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/101802 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libclang/python] Fix bug in `SourceRange.__contains__`, add tests (PR #101802)

2024-08-09 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/101802 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libclang/python] Fix bug in `SourceRange.__contains__`, add tests (PR #101802)

2024-08-09 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/101802 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libclang/python] Fix bug in `SourceRange.__contains__`, add tests (PR #101802)

2024-08-10 Thread Jannick Kremer via cfe-commits
@@ -386,6 +386,10 @@ def __contains__(self, other): # same file, in between lines if self.start.line < other.line < self.end.line: return True +# between columns in one-liner range +elif self.start.line == other.line == self.end.line:

[clang] [libclang/python] Fix bug in `SourceRange.__contains__`, add tests (PR #101802)

2024-08-10 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/101802 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] #101784 part 2: fix error handling of TranslationUnit.reparse (PR #102410)

2024-08-11 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum commented: A couple minor comments, and the code formatting should be fixed (see output of the failing CI run), and then this is good to go! https://github.com/llvm/llvm-project/pull/102410 ___ cfe-commits mailing list

[clang] #101784 part 2: fix error handling of TranslationUnit.reparse (PR #102410)

2024-08-11 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/102410 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] #101784 part 2: fix error handling of TranslationUnit.reparse (PR #102410)

2024-08-11 Thread Jannick Kremer via cfe-commits
@@ -161,7 +161,34 @@ class TranslationUnitLoadError(Exception): FIXME: Make libclang expose additional error information in this scenario. DeinAlptraum wrote: I would say your change resolves the `FIXME` here. Thanks for expanding this to the `create`/`pars

[clang] #101784 part 2: fix error handling of TranslationUnit.reparse (PR #102410)

2024-08-11 Thread Jannick Kremer via cfe-commits
@@ -59,6 +59,9 @@ Clang Python Bindings Potentially Breaking Changes - Calling a property on the `CompletionChunk` or `CompletionString` class statically now leads to an error, instead of returning a `CachedProperty` object that is used internally. Properties are only avai

[clang] #101784 part 2: fix error handling of TranslationUnit.reparse (PR #102410)

2024-08-11 Thread Jannick Kremer via cfe-commits
@@ -161,7 +161,34 @@ class TranslationUnitLoadError(Exception): FIXME: Make libclang expose additional error information in this scenario. """ -pass +# A generic error code, no further details are available. +# +# Errors of this kind can get their own s

[clang] #101784 part 2: fix error handling of TranslationUnit.reparse (PR #102410)

2024-08-11 Thread Jannick Kremer via cfe-commits
@@ -149,8 +149,8 @@ def b(x: str | bytes) -> bytes: # this by marshalling object arguments as void**. c_object_p: TType[_Pointer[Any]] = POINTER(c_void_p) -### Exception Classes ### +### Exception Classes ### DeinAlptraum wrote: Unnecessary whitespace chang

[clang] [NFC][libclang/python] Fix code highlighting in release notes (PR #102807)

2024-08-11 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum created https://github.com/llvm/llvm-project/pull/102807 This corrects a release note introduced in #98745 >From 64212e4c8afe2ad75144bf36a1212c4e417dd8c9 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Sun, 11 Aug 2024 11:00:52 +0200 Subject: [PATCH] [NFC][l

[clang] [NFC][libclang/python] Fix code highlighting in release notes (PR #102807)

2024-08-11 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum closed https://github.com/llvm/llvm-project/pull/102807 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NFC][libclang/python] Fix code highlighting in release notes (PR #102807)

2024-08-11 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: Unrelated, this change only touched release notes https://github.com/llvm/llvm-project/pull/102807 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libclang/python] Improve error reporting of `TranslationUnit` creating functions (PR #102410)

2024-08-11 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/102410 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libclang/python] Improve error reporting of `TranslationUnit` creating functions (PR #102410)

2024-08-11 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/102410 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libclang/python] Improve error reporting of `TranslationUnit` creating functions (PR #102410)

2024-08-11 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum approved this pull request. LGTM. Thanks for adding better error handling! @Endilll do you also want to take a look at this before it is merged? Otherwise, this is good to go imo. https://github.com/llvm/llvm-project/pull/102410 __

[clang] [libclang/python] Improve error reporting of `TranslationUnit` creating functions (PR #102410)

2024-08-11 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/102410 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libclang/python] Fix bug in `SourceRange.__contains__`, add tests (PR #101802)

2024-08-14 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/101802 >From 572b1be0b204561fdbb049f0c17f065d17198ac0 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Sat, 3 Aug 2024 09:28:02 +0100 Subject: [PATCH 1/3] [libclang/python] Fix bug in SourceRange.__contains__,

[clang] [libclang/python] Fix bug in `SourceRange.__contains__`, add tests (PR #101802)

2024-08-14 Thread Jannick Kremer via cfe-commits
@@ -386,6 +386,10 @@ def __contains__(self, other): # same file, in between lines if self.start.line < other.line < self.end.line: return True +# between columns in one-liner range +elif self.start.line == other.line == self.end.line:

[clang] [libclang/python] Fix bug in `SourceRange.__contains__`, add tests (PR #101802)

2024-08-14 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/101802 >From 572b1be0b204561fdbb049f0c17f065d17198ac0 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Sat, 3 Aug 2024 09:28:02 +0100 Subject: [PATCH 1/3] [libclang/python] Fix bug in SourceRange.__contains__,

[clang] [libclang/python] Fix bug in `SourceRange.__contains__`, add tests (PR #101802)

2024-08-14 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/101802 >From 572b1be0b204561fdbb049f0c17f065d17198ac0 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Sat, 3 Aug 2024 09:28:02 +0100 Subject: [PATCH 1/4] [libclang/python] Fix bug in SourceRange.__contains__,

[clang] [libclang/python] Fix bug in `SourceRange.__contains__`, add tests (PR #101802)

2024-08-14 Thread Jannick Kremer via cfe-commits
@@ -50,6 +50,18 @@ unsigned clang_equalLocations(CXSourceLocation loc1, CXSourceLocation loc2) { loc1.int_data == loc2.int_data); } +unsigned clang_lessThanLocations(CXSourceLocation loc1, CXSourceLocation loc2) { + const SourceLocation Loc1 = SourceLocation::get

[clang] [libclang/python] Fix bug in `SourceRange.__contains__`, add tests (PR #101802)

2024-08-14 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/101802 >From 572b1be0b204561fdbb049f0c17f065d17198ac0 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Sat, 3 Aug 2024 09:28:02 +0100 Subject: [PATCH 1/4] [libclang/python] Fix bug in SourceRange.__contains__,

[clang] [libclang/python] Fix bug in `SourceRange.__contains__`, add tests (PR #101802)

2024-08-14 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/101802 >From 572b1be0b204561fdbb049f0c17f065d17198ac0 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Sat, 3 Aug 2024 09:28:02 +0100 Subject: [PATCH 1/5] [libclang/python] Fix bug in SourceRange.__contains__,

[clang] [libclang/python] Fix bug in `SourceRange.__contains__`, add tests (PR #101802)

2024-08-14 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: Implemented all your suggestions https://github.com/llvm/llvm-project/pull/101802 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libclang/python] Fix bug in `SourceRange.__contains__`, add tests (PR #101802)

2024-08-15 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/101802 >From 572b1be0b204561fdbb049f0c17f065d17198ac0 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Sat, 3 Aug 2024 09:28:02 +0100 Subject: [PATCH 1/6] [libclang/python] Fix bug in SourceRange.__contains__,

[clang] [libclang/python] Fix bug in `SourceRange.__contains__`, add tests (PR #101802)

2024-08-15 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/101802 >From 572b1be0b204561fdbb049f0c17f065d17198ac0 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Sat, 3 Aug 2024 09:28:02 +0100 Subject: [PATCH 1/6] [libclang/python] Fix bug in SourceRange.__contains__,

[clang] [libclang/python] Fix bug in `SourceRange.__contains__`, add tests (PR #101802)

2024-08-15 Thread Jannick Kremer via cfe-commits
@@ -74,6 +74,16 @@ CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void); CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1, CXSourceLocation loc2); +/** + * Determine for two source locations if they refer to

[clang] [libclang/python] Fix bug in `SourceRange.__contains__`, add tests (PR #101802)

2024-08-15 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/101802 >From 572b1be0b204561fdbb049f0c17f065d17198ac0 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Sat, 3 Aug 2024 09:28:02 +0100 Subject: [PATCH 1/6] [libclang/python] Fix bug in SourceRange.__contains__,

[clang] [libclang/python] Fix bug in `SourceRange.__contains__`, add tests (PR #101802)

2024-08-15 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/101802 >From 572b1be0b204561fdbb049f0c17f065d17198ac0 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Sat, 3 Aug 2024 09:28:02 +0100 Subject: [PATCH 1/7] [libclang/python] Fix bug in SourceRange.__contains__,

[clang] [libclang/python] Fix bug in `SourceRange.__contains__`, add tests (PR #101802)

2024-08-15 Thread Jannick Kremer via cfe-commits
@@ -65,6 +65,9 @@ Clang Python Bindings Potentially Breaking Changes - Calling a property on the ``CompletionChunk`` or ``CompletionString`` class statically now leads to an error, instead of returning a ``CachedProperty`` object that is used internally. Properties are onl

[clang] [libclang/python] Fix bug in `SourceRange.__contains__`, add tests (PR #101802)

2024-08-15 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum closed https://github.com/llvm/llvm-project/pull/101802 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-06-09 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/78114 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-06-09 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/78114 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-06-09 Thread Jannick Kremer via cfe-commits
@@ -665,867 +1312,858 @@ class CursorKind(BaseEnumeration): A CursorKind describes the kind of entity that a cursor points to. """ -# The required BaseEnumeration declarations. -_kinds = [] -_name_map = None - @staticmethod -def get_all_kinds(): +

[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-06-09 Thread Jannick Kremer via cfe-commits
@@ -2286,192 +2869,151 @@ class TypeKind(BaseEnumeration): Describes the kind of type. """ -# The unique kind objects, indexed by id. -_kinds = [] -_name_map = None - @property -def spelling(self): +def spelling(self) -> str: """Retrie

[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-06-09 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/78114 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-06-09 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum ready_for_review https://github.com/llvm/llvm-project/pull/78114 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-06-09 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: Since https://github.com/llvm/llvm-project/issues/83962 is now closed and the minimum Python version updated to 3.8, this is now finally ready for review. I've updated this with the changes to the Python bindings of the past couple months. I have no idea idea what the erro

[clang] [libclang/python] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-06-09 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/78114 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libclang/python] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-06-10 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/78114 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libclang/python] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-06-10 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/78114 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libclang/python] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-06-10 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/78114 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libclang/python] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-06-11 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: Thanks a lot for your feedback! Yup I get that the PR is pretty big and might still need significant changes. > 1. I have maintainability concerns about `ClangLib` protocol [...] I completely agree that this is ugly, but I didn't find a better solution that would enable

[clang] [libclang/python] Fix bugs in custom enum implementation and add tests (PR #95381)

2024-06-13 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum created https://github.com/llvm/llvm-project/pull/95381 Do not allow initialization of enum from negative IDs (e.g. from_id(-1) currently produces the last known variant) Rename duplicate enums: CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE and TypeKind.OBJCCLASS Ad

[clang] [libclang/python] Fix bugs in custom enum implementation and add tests (PR #95381)

2024-06-13 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: @Endilll I separated the fixes for the enum bugs from the strict typing PR, and added tests that cover these cases. I checked that the tests fail before the fixes and succeed now. https://github.com/llvm/llvm-project/pull/95381 __

[clang] [libclang/python] Fix bugs in custom enum implementation and add tests (PR #95381)

2024-06-13 Thread Jannick Kremer via cfe-commits
@@ -2395,7 +2395,7 @@ def __repr__(self): TypeKind.OCLRESERVEID = TypeKind(160) TypeKind.OBJCOBJECT = TypeKind(161) -TypeKind.OBJCCLASS = TypeKind(162) +TypeKind.OBJCTYPEPARAM = TypeKind(162) DeinAlptraum wrote: This was a duplicate with variant 28 (OBJCCLASS

[clang] [libclang/python] Fix bugs in custom enum implementation and add tests (PR #95381)

2024-06-13 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/95381 >From bfc36e30e84c616adb8ff57754a49a5bb66d1dd9 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Thu, 13 Jun 2024 10:43:52 +0100 Subject: [PATCH] [libclang/python] Fix bugs in custom enum implementation an

[clang] [libclang/python] Fix bugs in custom enum implementation and add tests (PR #95381)

2024-06-13 Thread Jannick Kremer via cfe-commits
@@ -1336,7 +1336,7 @@ def __repr__(self): CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE = CursorKind(271) # OpenMP teams distribute simd directive. -CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE = CursorKind(272) +CursorKind.OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE = CursorKind(272) --

[clang] [libclang/python] Fix bugs in custom enum implementation and add tests (PR #95381)

2024-06-13 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/95381 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libclang/python] Fix bugs in custom enum implementation and add tests (PR #95381)

2024-06-13 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/95381 >From a3da142b0db6581581ccb135800d77b09476f385 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Thu, 13 Jun 2024 10:43:52 +0100 Subject: [PATCH 1/2] [libclang/python] Fix bugs in custom enum implementatio

[clang] [libclang/python] Fix bugs in custom enum implementation and add tests (PR #95381)

2024-06-13 Thread Jannick Kremer via cfe-commits
@@ -0,0 +1,50 @@ +import unittest + +from clang.cindex import ( +CursorKind, +TemplateArgumentKind, +ExceptionSpecificationKind, +AvailabilityKind, +AccessSpecifier, +TypeKind, +RefQualifierKind, +LinkageKind, +TLSKind, +StorageClass, +) + +

[clang] [libclang/python] Fix bugs in custom enum implementation and add tests (PR #95381)

2024-06-13 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: These were all the bugs I'd found, so I think it is https://github.com/llvm/llvm-project/pull/95381 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libclang/python] Fix bugs in custom enum implementation and add tests (PR #95381)

2024-06-13 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/95381 >From a3da142b0db6581581ccb135800d77b09476f385 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Thu, 13 Jun 2024 10:43:52 +0100 Subject: [PATCH 1/2] [libclang/python] Fix bugs in custom enum implementatio

[clang] [libclang/python] Fix bugs in custom enum implementation and add tests (PR #95381)

2024-06-13 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: @Endilll I merged the Python 3.8 CI into this PR and the CI run was successful (though it only ran on 3.8 for some reason), so can this be merged? https://github.com/llvm/llvm-project/pull/95381 ___ cfe-commits mailing list cfe-com

[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-06-14 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum created https://github.com/llvm/llvm-project/pull/95608 Use Python's builtin enum class instead of writing our own. This is preparation for passing a strict type check in PR #78114 , fixing 920 out of 1341 strict typing errors >From 35bfcfbc69ee812c59350440b7b1

[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-06-14 Thread Jannick Kremer via cfe-commits
@@ -611,51 +612,25 @@ def register(value, name): ### Cursor Kinds ### -class BaseEnumeration: +class BaseEnumeration(Enum): """ Common base class for named enumerations held in sync with Index.h values. - -Subclasses must define their own _kinds and _name_map me

[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-06-14 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/95608 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-06-14 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum commented: There is also `TokenKind`: this one does not currently inherit from `BaseEnumeration` and is defined somewhat differently, having all its variants and their IDs as a dictionary in `enumerations.py`. This seems quite arbitrary to me, is there any reaso

[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-06-14 Thread Jannick Kremer via cfe-commits
@@ -31,17 +31,9 @@ class TestCursorKind(unittest.TestCase): def test_from_id(self): """Check that kinds can be constructed from valid IDs""" for enum in self.enums: -self.assertEqual(enum.from_id(2), enum._kinds[2]) +self.assertEqual(

[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-06-14 Thread Jannick Kremer via cfe-commits
@@ -611,51 +612,25 @@ def register(value, name): ### Cursor Kinds ### -class BaseEnumeration: +class BaseEnumeration(Enum): """ Common base class for named enumerations held in sync with Index.h values. - -Subclasses must define their own _kinds and _name_map me

[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-06-14 Thread Jannick Kremer via cfe-commits
@@ -611,51 +612,25 @@ def register(value, name): ### Cursor Kinds ### -class BaseEnumeration: +class BaseEnumeration(Enum): """ Common base class for named enumerations held in sync with Index.h values. - -Subclasses must define their own _kinds and _name_map me

[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-06-14 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: @Endilll can I ask you for a review again? As a next step towards the python-bindings strict typing PR, this one captures all the enum refactoring changes necessary towards that goal. Don't be scared by the LoC changed: 90% of that is just indentation changes :) https://git

[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-06-15 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/95608 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libclang/python] Fix some type errors, add type annotations (PR #98745)

2024-07-23 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/98745 >From c64b124ccc22cd9f92b0a55f60ec92d7101d0048 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Sat, 13 Jul 2024 14:12:34 +0100 Subject: [PATCH 1/2] [libclang/python] Fix some type errors, add type annot

[clang] [libclang/python] Fix some type errors, add type annotations (PR #98745)

2024-07-23 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: Since the release branching is done, I've rebased on main to fix the release notes https://github.com/llvm/llvm-project/pull/98745 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listi

[clang] [libclang/python] Export all enums (PR #100941)

2024-07-28 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum created https://github.com/llvm/llvm-project/pull/100941 This resolves #48212 and also adds the remaining unexposed Enums >From c4007832c8ed7cdb56aceebcf61b24ecb75f2aa4 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Sun, 28 Jul 2024 18:30:35 +0100 Subject:

[clang] [libclang/python] Export all enums (PR #100941)

2024-07-28 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: @Endilll can I ask you for a review again? https://github.com/llvm/llvm-project/pull/100941 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libclang/python] Export all enums (PR #100941)

2024-07-29 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: Could you also merge please? (or are you waiting for something else?) https://github.com/llvm/llvm-project/pull/100941 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commi

[clang] [libclang/python] Export all enums (PR #100941)

2024-07-29 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/100941 >From 4b1322b8add0a1189f0f1cbf5583841f3a591f0c Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Sun, 28 Jul 2024 18:30:35 +0100 Subject: [PATCH] [libclang/python] Export all enums --- clang/bindings/py

[clang] [libclang/python] Fix some type errors, add type annotations (PR #98745)

2024-07-29 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/98745 >From 00631fc559197d2bc6bfa9e8ccdae47f33926a37 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Sat, 13 Jul 2024 14:12:34 +0100 Subject: [PATCH 1/2] [libclang/python] Fix some type errors, add type annot

[clang] [libclang/python] Export all enums (PR #100941)

2024-07-29 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: This may be my fault, I don't remember if I pulled main before branching for this PR, especially seeing how my last PR also had unrelated test failures https://github.com/llvm/llvm-project/pull/100941 ___ cfe-commits mailing list c

[clang] [Clang][Sema] Remove duplicate check in if-condition (PR #101070)

2024-07-29 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum created https://github.com/llvm/llvm-project/pull/101070 Resolves #101041 >From 521082f25bc42104fd436a412b2de2edb60b7b0e Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Mon, 29 Jul 2024 20:24:15 +0100 Subject: [PATCH] [Clang][Sema] Remove duplicate check in

  1   2   3   4   >