[clang] Add retrieval of unary operator spelling and python bindings (PR #219983)

Jannick Kremer via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 15 16:55:47 PDT 2026


================
@@ -2474,6 +2487,38 @@ def is_assignment(self):
     Comma = 33
 
 
+class UnaryOperator(BaseEnumeration):
+    """
+    Describes the UnaryOperator of a declaration
+    """
+
+    def __nonzero__(self):
----------------
DeinAlptraum wrote:

It also doesn't seem to work the way the doc comments suggest:

```
import cindex 

print("PostInc nonzero:", cindex.UnaryOperator.PostInc.__nonzero__())
print("Invalid nonzero:", cindex.UnaryOperator.Invalid.__nonzero__())

if cindex.UnaryOperator.PostInc:
    print("PostInc is true")

if cindex.UnaryOperator.Invalid:
    print("Invalid is true")
```

```
~/.../python/clang >>> python att.py                            ±[●][219983] [8:52:21]
PostInc nonzero: True
Invalid nonzero: False
PostInc is true
Invalid is true

```

As this is copying the existing case from `BinaryOperator` we will have to fix that one separately as well.

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


More information about the cfe-commits mailing list