[PATCH] D10833: Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface

Kevin Funk via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 4 00:57:55 PST 2015


kfunk added inline comments.

================
Comment at: bindings/python/clang/cindex.py:1589
@@ +1588,3 @@
+    def is_assignment(self):
+        return BinaryOperator.Assign.value <= self.value < BinaryOperator.Comma.value
+
----------------
TIL chaining comparisons in Python is OK... :)

I first though this expression gives the wrong result and you need `min <= val and val < max`. But indeed your expression does exactly this...

================
Comment at: bindings/python/tests/cindex/test_cursor.py:333
@@ +332,3 @@
+        # not exposed yet
+        # ".*" : BinaryOperator.PtrMemD,
+        "->*" : BinaryOperator.PtrMemI,
----------------
What about this? How is it not exposed? 

This works in the C++ test apparently(?)

================
Comment at: tools/libclang/CIndex.cpp:6749
@@ -6743,1 +6748,3 @@
 
+enum CX_BinaryOperatorKind clang_Cursor_getBinaryOpCode(CXCursor C) {
+	if (C.kind != CXCursor_BinaryOperator &&
----------------
I'd rename to `getBinaryOpcode` (note the casing, more consistent).

Same below, rename to `getBinaryOpcodeString` (casing + full words)

================
Comment at: tools/libclang/CIndex.cpp:6763
@@ +6762,3 @@
+
+CXString clang_Cursor_getBinaryOpCodeStr(CXCursor C) {
+	if (C.kind != CXCursor_BinaryOperator &&
----------------
I think this should have a `enum CX_BinaryOperatorKind` as parameter instead.

There's `BinaryOperator::getOpcode(Opcode)` you can use.


http://reviews.llvm.org/D10833





More information about the cfe-commits mailing list