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

Jannick Kremer via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 12 04:19:44 PDT 2024


================
@@ -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:
+        """
+
+        if not hasattr(self, "_binopcode"):
+            self._binopcode = conf.lib.clang_Cursor_getBinaryOpcode(self)
----------------
DeinAlptraum wrote:

Have you checked that the tests pass? I am not completely sure about the inner workings of this, but it seems  to me that all `conf.lib` functions should be registered with the lib object by adding an entry for the function in the `functionlist` object at the end of the file.
For comparison, see e.g. `clang_Cursor_getOffsetOfField`

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


More information about the cfe-commits mailing list