[PATCH] D150910: [libclang] Add CXBinaryOperatorKind and CXUnaryOperatorKind (implements 29138)
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 9 05:03:52 PDT 2023
aaron.ballman added a comment.
In D150910#4406296 <https://reviews.llvm.org/D150910#4406296>, @MineGame159 wrote:
> I have added the new functions into the file and now it successfully compiles the test. (but fails when running it - EDIT: guess I broke my dev env somehow)
>
> Also checked and made sure that `CINDEX_VERSION_MINOR` was already incremented in LLVM 17.
> Another thing I am not sure is which naming convention I should be using. Some functions in the C api use `clang_getCursorBinaryOperatorKind` and others `clang_Cursor_getBinaryOperatorKind`.
The style you're using currently is fine.
================
Comment at: clang/docs/ReleaseNotes.rst:720
+- Add ``CXBinaryOperatorKind`` and ``CXUnaryOperatorKind``.
+ (`#29138 <https://github.com/llvm/llvm-project/issues/29138>`_)
----------------
================
Comment at: clang/tools/libclang/CIndex.cpp:9620-9624
+ if (const BinaryOperator *op = dyn_cast<BinaryOperator>(expr))
+ return static_cast<CXBinaryOperatorKind>(op->getOpcode() + 1);
+
+ if (const CXXRewrittenBinaryOperator *op =
+ dyn_cast<CXXRewrittenBinaryOperator>(expr))
----------------
Sorry, I was unclear before. :-) Our style guide is to not use `auto` unless the type is spelled out explicitly in the RHS of the assignment (basically, use `auto` when it lets you avoid repeating the type name). So these uses with `dyn_cast` (and friends) should use `auto`, while a call like `getCursorExpr()` should spell out the type explicitly.
================
Comment at: clang/tools/libclang/CIndex.cpp:9640
+
+ if (const UnaryOperator *op = dyn_cast<UnaryOperator>(expr))
+ return static_cast<CXUnaryOperatorKind>(op->getOpcode() + 1);
----------------
================
Comment at: clang/unittests/libclang/LibclangTest.cpp:1143
+ std::string Main = "main.cpp";
+ WriteFile(Main, "int foo() { return 5 + 9; };");
+ ClangTU = clang_parseTranslationUnit(Index, Main.c_str(), nullptr, 0, nullptr,
----------------
================
Comment at: clang/unittests/libclang/LibclangTest.cpp:1160
+ std::string Main = "main.cpp";
+ WriteFile(Main, "int foo() { int a = 5; return a++; };");
+ ClangTU = clang_parseTranslationUnit(Index, Main.c_str(), nullptr, 0, nullptr,
----------------
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150910/new/
https://reviews.llvm.org/D150910
More information about the cfe-commits
mailing list