[clang] Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface (PR #98489)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 11 10:44:52 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {darker}-->
:warning: Python code formatter, darker found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
darker --check --diff -r 8b7263ba3051125ab2bb9df514bdaadaca1b637d...04b1daff1ee00e0f26dc510670c084fec98453ac clang/bindings/python/clang/cindex.py clang/bindings/python/tests/cindex/test_cursor.py
``````````
</details>
<details>
<summary>
View the diff from darker here.
</summary>
``````````diff
--- clang/cindex.py 2024-07-11 14:33:20.000000 +0000
+++ clang/cindex.py 2024-07-11 17:44:26.235501 +0000
@@ -1897,11 +1897,11 @@
"""
Retrieves the opcode if this cursor points to a binary operator
:return:
"""
- if not hasattr(self, '_binopcode'):
+ if not hasattr(self, "_binopcode"):
self._binopcode = conf.lib.clang_Cursor_getBinaryOpcode(self)
return BinaryOperator.from_id(self._binopcode)
@property
@@ -2191,29 +2191,31 @@
return None
res._tu = args[0]._tu
return res
+
class BinaryOperator(BaseEnumeration):
"""
Describes the BinaryOperator of a declaration
"""
# The unique kind objects, index by id.
_kinds = []
_name_map = None
def __nonzero__(self):
- """ Allows checks of the kind ```if cursor.binary_operator:```"""
+ """Allows checks of the kind ```if cursor.binary_operator:```"""
return self.value != 0
@property
def is_assignment(self):
return BinaryOperator.Assign.value <= self.value < BinaryOperator.Comma.value
def __repr__(self):
- return 'BinaryOperator.%s' % (self.name,)
+ return "BinaryOperator.%s" % (self.name,)
+
BinaryOperator.Invalid = BinaryOperator(0)
BinaryOperator.PtrMemD = BinaryOperator(1)
BinaryOperator.PtrMemI = BinaryOperator(2)
BinaryOperator.Mul = BinaryOperator(3)
``````````
</details>
https://github.com/llvm/llvm-project/pull/98489
More information about the cfe-commits
mailing list