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

2024-07-29 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: @zyn0217 I hope you're the right person to ask for a review here? https://github.com/llvm/llvm-project/pull/101070 ___ 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-07-30 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/78114 >From 717c43a4c027681fa957ed35a365400c129ff0b1 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Fri, 12 Jul 2024 15:08:06 +0100 Subject: [PATCH] [libclang/python] Add strict typing to clang Python binding

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

2024-07-30 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/78114 >From d16056310b86aaa98011cb8551c38365f0e7748f Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Fri, 12 Jul 2024 15:08:06 +0100 Subject: [PATCH] [libclang/python] Add strict typing to clang Python binding

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

2024-07-30 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/78114 >From 883bda054bb6a70edd2f2d738ffccff3a0b47a35 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Fri, 12 Jul 2024 15:08:06 +0100 Subject: [PATCH] [libclang/python] Add strict typing to clang Python binding

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

2024-07-30 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/78114 >From 6f93e30dc7fdeaa18ae181c15aaed257c902d4c8 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Fri, 12 Jul 2024 15:08:06 +0100 Subject: [PATCH] [libclang/python] Add strict typing to clang Python binding

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

2024-07-30 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: I rebased this on the other changes, so there's mostly relatively simple annotations left now. Still a few hundred of them though. @Endilll do you want me to split this further, or is this fine? https://github.com/llvm/llvm-project/pull/78114 ___

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

2024-07-31 Thread Jannick Kremer via cfe-commits
@@ -3257,21 +3323,21 @@ def reparse(self, unsaved_files=None, options=0): if unsaved_files is None: unsaved_files = [] -unsaved_files_array = 0 +unsaved_files_array: int | Array[_CXUnsavedFile] = 0 if len(unsaved_files):

[clang] [libclang/python] Factor out unsaved files processing (PR #101308)

2024-07-31 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum created https://github.com/llvm/llvm-project/pull/101308 Factor out the processing of unsaved files into its own function as suggested by @Endilll [here](https://github.com/llvm/llvm-project/pull/78114/files#r1697730196) >From 8780961064341bbbfd6cf97d9c6d5a4f7

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

2024-07-31 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] type-ignore `Any` returns from library calls (PR #101310)

2024-07-31 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum created https://github.com/llvm/llvm-project/pull/101310 On its own, this change leads to _more_ strict typing errors as the functions are mostly not annotated so far, so the `# type: ignore`s are reported as Unused. This is part of the work leading up to #78114

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

2024-07-31 Thread Jannick Kremer via cfe-commits
@@ -255,71 +263,75 @@ 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)

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

2024-07-31 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/78114 >From 04641f7ea15382df2d43fecc32bd1b699e0b2481 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Fri, 12 Jul 2024 15:08:06 +0100 Subject: [PATCH] [libclang/python] Add strict typing to clang Python binding

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

2024-07-31 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: I'm planning to do one last split that contains all "logic" changes, after which this PR should contain only actual typing annotations and nothing else. Will open a PR for that other change one of these days https://github.com/llvm/llvm-project/pull/78114 __

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

2024-07-19 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: \*Ping* @Endilll do you have time to take a look at this? https://github.com/llvm/llvm-project/pull/98745 ___ 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-21 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/98745 >From c0216b8a50f7ccc6ee24db69802055c3942a183e 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-21 Thread Jannick Kremer via cfe-commits
@@ -200,13 +236,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] [libclang/python] Fix some type errors, add type annotations (PR #98745)

2024-07-21 Thread Jannick Kremer via cfe-commits
@@ -66,46 +66,77 @@ import collections.abc import os +import sys from enum import Enum +from typing import ( +Any, +Callable, +Generic, +Optional, +Type as TType, +TypeVar, +TYPE_CHECKING, +Union as TUnion, +) +from typing_extensions import P

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

2024-07-21 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: I added breaking change notes where I thought them appropriate, could you merge if you are happy with this? Regarding the relase: I believe I've taken care not to break anything (besides things noted in breaking change notes) so hopefully not much need for that. If any une

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

2024-07-21 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: @nikic could you explain why? https://github.com/llvm/llvm-project/pull/98745 ___ 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-21 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: Got it, thank you! https://github.com/llvm/llvm-project/pull/98745 ___ 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-11 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: *Ping\* @Endilll how should we proceed with this? 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-11 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/4] [libclang/python] Refactor enum usage Use Python's bui

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

2024-07-11 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-07-11 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: Hmm what do you think should be mentioned in a release note @Endilll ? Since this is just refactoring, if I did everything correctly, users of the bindings should not notice any difference (except for different error messages). So just mention refactoring of enums in the bin

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

2024-07-11 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/5] [libclang/python] Refactor enum usage Use Python's bui

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

2024-07-11 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: I added a release note to the `Clang Python Bindings Potentially Breaking Changes` section https://github.com/llvm/llvm-project/pull/95608 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailm

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

2024-07-11 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/6] [libclang/python] Refactor enum usage Use Python's bui

[clang] Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface (PR #98489)

2024-07-11 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: For a quick overview of the changes you'll need to make after #95608 in the Python bindings: - remove `_kind`, `_name_map` and `__repr__()` from the `BinaryOperator` definition - declare all variants of `BinaryOperator` within the class definition, i.e. `Invalid = 0` inste

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

2024-07-12 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: CI is done, so could you merge this? Thanks for the reviews and support @Endilll! https://github.com/llvm/llvm-project/pull/95608 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listin

[clang] Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface (PR #98489)

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

[clang] Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface (PR #98489)

2024-07-12 Thread Jannick Kremer via cfe-commits
@@ -1820,6 +1820,18 @@ def availability(self): return AvailabilityKind.from_id(self._availability) +@property +def binary_operator(self): +""" +Retrieves the opcode if this cursor points to a binary operator +:return: +""" + +

[clang] Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface (PR #98489)

2024-07-12 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum commented: The Python changes look good to me, just one part that might need changes. Can someone approve the CI workflows so we also get the results for the bindings tests to confirm? https://github.com/llvm/llvm-project/pull/98489 __

[clang] Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface (PR #98489)

2024-07-12 Thread Jannick Kremer via cfe-commits
@@ -1820,6 +1820,18 @@ def availability(self): return AvailabilityKind.from_id(self._availability) +@property +def binary_operator(self): +""" +Retrieves the opcode if this cursor points to a binary operator +:return: +""" + +

[clang] Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface (PR #98489)

2024-07-13 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: LGTM! https://github.com/llvm/llvm-project/pull/98489 ___ 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-13 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum created https://github.com/llvm/llvm-project/pull/98745 This fixes a few of the more debatable type errors, and adds related annotations, as the next step towards #76664. >From 06483bd3e398dd9dba757904e622d5dd1b37db77 Mon Sep 17 00:00:00 2001 From: Jannick Kreme

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

2024-07-13 Thread Jannick Kremer via cfe-commits
@@ -43,7 +43,7 @@ Most object information is exposed using properties, when the underlying API call is efficient. """ -from __future__ import absolute_import, division, print_function DeinAlptraum wrote: All of these are already activated by default since Pyth

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

2024-07-13 Thread Jannick Kremer via cfe-commits
@@ -66,46 +66,77 @@ import collections.abc import os +import sys DeinAlptraum wrote: This is used for `sys.stdout.flush()` in this file, and leads to a type error. I don't know why this isn't already imported https://github.com/llvm/llvm-project/pull/98745

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

2024-07-13 Thread Jannick Kremer via cfe-commits
@@ -200,13 +236,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] [libclang/python] Fix some type errors, add type annotations (PR #98745)

2024-07-13 Thread Jannick Kremer via cfe-commits
@@ -115,9 +146,7 @@ def b(x): # object. This is a problem, because it means that from_parameter will see an # integer and pass the wrong value on platforms where int != void*. Work around # this by marshalling object arguments as void**. -c_object_p = POINTER(c_void_p) - -callb

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

2024-07-13 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/98745 ___ 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-13 Thread Jannick Kremer via cfe-commits
@@ -66,46 +66,77 @@ import collections.abc import os +import sys from enum import Enum +from typing import ( +Any, +Callable, +Generic, +Optional, +Type as TType, +TypeVar, +TYPE_CHECKING, +Union as TUnion, +) +from typing_extensions import P

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

2024-07-13 Thread Jannick Kremer via cfe-commits
@@ -66,46 +66,77 @@ import collections.abc import os +import sys from enum import Enum +from typing import ( +Any, +Callable, +Generic, +Optional, +Type as TType, +TypeVar, +TYPE_CHECKING, +Union as TUnion, +) +from typing_extensions import P

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

2024-07-13 Thread Jannick Kremer via cfe-commits
@@ -3895,28 +3932,28 @@ def register_function(lib, item, ignore_errors): func.errcheck = item[3] -def register_functions(lib, ignore_errors): +def register_functions(lib: CDLL, ignore_errors: bool) -> None: """Register function prototypes with a libclang library

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

2024-07-13 Thread Jannick Kremer via cfe-commits
@@ -169,25 +198,32 @@ def __init__(self, enumeration, message): ### Structures and Utility Classes ### +TInstance = TypeVar("TInstance") +TResult = TypeVar("TResult") + -class CachedProperty: +class CachedProperty(Generic[TInstance, TResult]): """Decorator that lazy-lo

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

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

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

2024-07-13 Thread Jannick Kremer via cfe-commits
@@ -2318,25 +2356,25 @@ def kind(self): """Return the kind of this type.""" return TypeKind.from_id(self._kind_id) -def argument_types(self): +def argument_types(self) -> NoSliceSequence[Type]: """Retrieve a container for the non-variadic argum

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

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

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

2024-07-13 Thread Jannick Kremer via cfe-commits
@@ -64,48 +64,81 @@ from ctypes import * -import collections.abc import os +import sys from enum import Enum +from typing import ( +Any, +Callable, +Generic, +Optional, +Type as TType, +TypeVar, +TYPE_CHECKING, +Union as TUnion, +) +from ty

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

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

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

2024-07-13 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: @Endilll I am once again asking for your support This PR collects several of the changes towards #78114 that I assume might need some discussion. I tried to leave PR comments with explanations in each of those places. @boomanaiden154 @linux4life798 review from you would also

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

2024-07-13 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/98745 ___ 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-13 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/98745 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libclang/python] Fix get_exception_specification_kind (PR #101548)

2024-08-01 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum created https://github.com/llvm/llvm-project/pull/101548 This fixes a bug with `get_exception_ specification_kind`. The function did not work before. Also add a test that confirms that it works now. >From 7e5ff53e8dc56e15f84c3868a25a779be54a22f0 Mon Sep 17 00:00

[clang] [libclang/python] Fix get_exception_specification_kind (PR #101548)

2024-08-01 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/101548 >From e7e66f0f90d7fb9adf3d3f546becd87c7527fa4c Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Thu, 1 Aug 2024 20:01:34 +0100 Subject: [PATCH] [libclang/python] Fix get_exception_specification_kind ---

[clang] [libclang/python] Fix get_exception_specification_kind (PR #101548)

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

[clang] [libclang/python] Fix get_exception_specification_kind (PR #101548)

2024-08-02 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/101548 >From e7e66f0f90d7fb9adf3d3f546becd87c7527fa4c Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Thu, 1 Aug 2024 20:01:34 +0100 Subject: [PATCH 1/2] [libclang/python] Fix get_exception_specification_kind

[clang] [libclang/python] Fix get_exception_specification_kind (PR #101548)

2024-08-02 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: I can't think of any more genereal approach that prevents this sort of problem. Type checking would help with this (e.g. giving an error when an unknown attribute is called on an object) though it wouldn't have worked in this specific case... otherwise nothing to do but add

[clang] [libclang/python] Fix `get_exception_specification_kind` (PR #101548)

2024-08-02 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: Could you merge this for me? On related note, do you think my contributions would count for "a track record of submitting high quality patches", i.e. should I apply for commit access? https://github.com/llvm/llvm-project/pull/101548 _

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

2024-08-03 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum created https://github.com/llvm/llvm-project/pull/101802 This resolves #22617 and #52827 >From 444d9480cf9629c81ae26636922af20db5bd52bf Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Sat, 3 Aug 2024 09:28:02 +0100 Subject: [PATCH] [libclang/python] Fix bug

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

2024-08-03 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] Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface (PR #98489)

2024-08-03 Thread Jannick Kremer via cfe-commits
@@ -54,6 +54,8 @@ LLVM_13 { clang_Cursor_Evaluate; clang_Cursor_getArgument; clang_Cursor_getBriefCommentText; +clang_Cursor_getBinaryOpcode; +clang_Cursor_getBinaryOpcodeStr; DeinAlptraum wrote: This is the `LLVM_13` section of the file. >

[clang] Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface (PR #98489)

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

[clang] Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface (PR #98489)

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

[clang] Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface (PR #98489)

2024-08-03 Thread Jannick Kremer via cfe-commits
@@ -54,6 +54,8 @@ LLVM_13 { clang_Cursor_Evaluate; clang_Cursor_getArgument; clang_Cursor_getBriefCommentText; +clang_Cursor_getBinaryOpcode; +clang_Cursor_getBinaryOpcodeStr; DeinAlptraum wrote: I will open a fix PR rightaway https://gith

[clang] [libclang] Move getBinaryOpcode library functions to LLVM 19 (PR #101820)

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

[clang] [libclang] Move getBinaryOpcode library functions to LLVM 19 (PR #101820)

2024-08-03 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum created https://github.com/llvm/llvm-project/pull/101820 None >From aff16c3b3a0cb7065a5ac143ae06850bbbeb666a Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Sat, 3 Aug 2024 13:43:41 +0100 Subject: [PATCH] [libclang] Move getBinaryOpcode library functions to

[clang] [libclang] Move getBinaryOpcode library functions to LLVM 19 (PR #101820)

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

[clang] [libclang] Fix symbol version of `getBinaryOpcode` functions (PR #101820)

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

[clang] Fix all mypy --strict errors in clang python binding (PR #101784)

2024-08-03 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: @TsXor thank you for your work! I am generally all in favor of typing annotations, and I like that `ctyped` adds a stronger connection between the Python function definitions and the C library functions in terms of types. That said, this PR is pretty massive and grows the P

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

2024-08-06 Thread Jannick Kremer via cfe-commits
@@ -64,48 +64,80 @@ from ctypes import * -import collections.abc import os +import sys from enum import Enum +from typing import ( +Any, +Callable, +Generic, +Optional, +Type as TType, +TypeVar, +TYPE_CHECKING, +Union as TUnion, +) + +if TY

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

2024-08-06 Thread Jannick Kremer via cfe-commits
@@ -64,48 +64,80 @@ from ctypes import * -import collections.abc import os +import sys from enum import Enum +from typing import ( +Any, +Callable, +Generic, +Optional, +Type as TType, +TypeVar, +TYPE_CHECKING, +Union as TUnion, +) + +if TY

[clang] #101784 part 1: introduce ctyped in an independent manner (PR #101941)

2024-08-06 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum commented: I agree with what Endill said: this is a rather big change and I'm not sure I see it adding enough value to justify this. It also adds quite some complexity on top of the otherwise relatively light-weight Python bindings. I generally like seeing change

[clang] #101784 part 1: introduce ctyped in an independent manner (PR #101941)

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

[clang] #101784 part 1: introduce ctyped in an independent manner (PR #101941)

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

[clang] #101784 part 1: introduce ctyped in an independent manner (PR #101941)

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

[clang] #101784 part 1: introduce ctyped in an independent manner (PR #101941)

2024-08-06 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: Regarding the segfault: this was a purely local problem for me, the function runs just fine for me now, and has always run fine in tests in the CI. I only left that comment to indicate that I couldn't test that specific part. https://github

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

2024-08-06 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] Fix bug in `SourceRange.__contains__`, add tests (PR #101802)

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

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

2024-08-07 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-07 Thread Jannick Kremer via cfe-commits
@@ -269,6 +269,14 @@ def _get_instantiation(self): f = None self._data = (f, int(l.value), int(c.value), int(o.value)) return self._data + +def __le__(self, other): +if self.line < other.line: +return True +

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

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

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

2024-08-07 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] #101784 part 2: fix error handling of TranslationUnit.reparse (PR #102410)

2024-08-08 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-08 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum commented: Thanks for this change! Looks good to me, aside from a few minor comments, most importantly a release note. Generally: for PR titles, a prefix ala "[libclang/python]" woud be good to denote the component or area of the code base, and empty description

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

2024-08-08 Thread Jannick Kremer via cfe-commits
@@ -152,6 +152,41 @@ def b(x: str | bytes) -> bytes: ### Exception Classes ### +class CXError(Exception): +'''Represents C error of type enum CXErrorCode.''' + +# A generic error code, no further details are available. +# +# Errors of this kind can get their o

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

2024-08-08 Thread Jannick Kremer via cfe-commits
@@ -3263,9 +3298,11 @@ def reparse(self, unsaved_files=None, options=0): unsaved_files = [] unsaved_files_array = self.process_unsaved_files(unsaved_files) -ptr = conf.lib.clang_reparseTranslationUnit( +result = conf.lib.clang_reparseTransla

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

2024-08-08 Thread Jannick Kremer via cfe-commits
@@ -152,6 +152,41 @@ def b(x: str | bytes) -> bytes: ### Exception Classes ### +class CXError(Exception): DeinAlptraum wrote: We already have a similar case with the bindings' `CXSaveError` for `clang_saveTranslationUnit` on the C side, for which we've impl

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

2024-08-08 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-08 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 1: introduce ctyped in an independent manner (PR #101941)

2024-08-08 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: @Endilll thanks a lot for the summary! Turning this into documentation also sounds like a good idea. 15\. & 16. fully agree it would be nicer to go without using this `errcheck` functionality, and just call the conversion functions directly. Even if the documentation appro

[clang] #101784 part 1: introduce ctyped in an independent manner (PR #101941)

2024-08-08 Thread Jannick Kremer via cfe-commits
DeinAlptraum wrote: > If you mean conf.lib.clang_Cursor_getTemplateArgumentKind, then it just > happened to be that exception. That one worked fine for me (need the args passed as well, but that's it), I meant the `SourceLocation` example with `clang_getRangeStart` below that https://github.c

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

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

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

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

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

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

[clang] [libclang/python] Do not rely on `ctypes`' `errcheck` (PR #105490)

2024-08-21 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum created https://github.com/llvm/llvm-project/pull/105490 Call conversion functions directly instead of using them for type conversion on library function calls via `ctypes`' `errcheck` functionality. >From 8cf94c6486b47cbe4f9ec82cc7c8a9c4948ed012 Mon Sep 17 00:0

[clang] [libclang/python] Do not rely on `ctypes`' `errcheck` (PR #105490)

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

[clang] [libclang/python] Do not rely on `ctypes`' `errcheck` (PR #105490)

2024-08-21 Thread Jannick Kremer via cfe-commits
https://github.com/DeinAlptraum commented: @Endilll this removes the `errcheck` magic conversion stuff that we discussed the other day https://github.com/llvm/llvm-project/pull/105490 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lis

[clang] [libclang/python] Do not rely on `ctypes`' `errcheck` (PR #105490)

2024-08-21 Thread Jannick Kremer via cfe-commits
@@ -424,7 +424,7 @@ def location(self): @property def spelling(self): -return conf.lib.clang_getDiagnosticSpelling(self) # type: ignore [no-any-return] +return _CXString.from_result(conf.lib.clang_getDiagnosticSpelling(self)) DeinAlp

[clang] [libclang/python] Do not rely on `ctypes`' `errcheck` (PR #105490)

2024-08-21 Thread Jannick Kremer via cfe-commits
@@ -3743,82 +3765,62 @@ def write_main_file_to_stdout(self): ("clang_equalLocations", [SourceLocation, SourceLocation], bool), ("clang_equalRanges", [SourceRange, SourceRange], bool), ("clang_equalTypes", [Type, Type], bool), -("clang_formatDiagnostic", [Diagnos

[clang] [libclang/python] Do not rely on `ctypes`' `errcheck` (PR #105490)

2024-08-21 Thread Jannick Kremer via cfe-commits
@@ -2454,7 +2480,7 @@ def element_type(self): If accessed on a type that is not an array, complex, or vector type, an exception will be raised. """ -result = conf.lib.clang_getElementType(self) +result = Type.from_result(conf.lib.clang_ge

<    1   2   3   4   5   >