[PATCH] D150910: [libclang] Add CXBinaryOperatorKind and CXUnaryOperatorKind (implements 29138)
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 6 13:23:15 PDT 2023
aaron.ballman added a comment.
Thank you for the additions! This should have some amount of test coverage added to clang/unittests/libclang/LibclangTest.cpp and a release note.
================
Comment at: clang/tools/libclang/CIndex.cpp:9606
+
+CXString clang_getBinaryOperatorKindSpelling(enum CXBinaryOperatorKind kind) {
+ switch (kind) {
----------------
Instead of implementing this manually, I think this should do:
```
return cxstring::createRef(BinaryOperator::getOpcodeStr(kind - 1));
```
(Similar for unary operators, may need casts to compile properly).
================
Comment at: clang/tools/libclang/CIndex.cpp:9683
+ if (clang_isExpression(cursor.kind)) {
+ auto expr = getCursorExpr(cursor);
+
----------------
Please spell out the type.
================
Comment at: clang/tools/libclang/CIndex.cpp:9685-9689
+ if (auto op = dyn_cast<BinaryOperator>(expr))
+ return static_cast<CXBinaryOperatorKind>(op->getOpcode() + 1);
+
+ if (auto op = dyn_cast<CXXRewrittenBinaryOperator>(expr))
+ return static_cast<CXBinaryOperatorKind>(op->getOpcode() + 1);
----------------
Similar for unary operators.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150910/new/
https://reviews.llvm.org/D150910
More information about the cfe-commits
mailing list