Hello,
this is my first patch proposal so please for give me if i made some
mistakes.
This patch changes the result of clang_getCursorSpelling in the way that
it returns the operator for
CXCursor_BinaryOperator/CXCursor_UnaryOperator instead of an empty string.
So e.g. for a + b it returns: +
I would like to know if such a change is welcome or if maybe the
current behavior is intended in a way i failed to perceive.
If yes i would provide a patch which also includes updated tests.
Best Regards,
Markus Lottmann
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index f220ea1..8ac5301 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -4240,6 +4240,18 @@ CXString clang_getCursorSpelling(CXCursor C) {
return cxstring::createDup(Spell);
}
+ if (C.kind == CXCursor_BinaryOperator) {
+ const BinaryOperator *BinOp = cast<BinaryOperator>(E);
+ return cxstring::createDup(
+ BinaryOperator::getOpcodeStr(BinOp->getOpcode()));
+ }
+
+ if (C.kind == CXCursor_UnaryOperator) {
+ const UnaryOperator *UnOp = cast<UnaryOperator>(E);
+ return cxstring::createDup(
+ UnaryOperator::getOpcodeStr(UnOp->getOpcode()));
+ }
+
const Decl *D = getDeclFromExpr(getCursorExpr(C));
if (D)
return getDeclSpelling(D);
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits