[cfe-dev] Request for libClang: CXCursor_UnaryOperator CXCursor_BinaryOperator spelling.
Felipe Lotas via cfe-dev
cfe-dev at lists.llvm.org
Thu Oct 17 02:49:47 PDT 2019
This message is a request to libClang developers. I'm not sure this is the right mailing list to ask for.
I'm using libClang API (simple C), not libTooling (C++).
I'd like to get the cursor spelling of unary (CXCursor_UnaryOperator) and binary (CXCursor_BinaryOperator) operators correctly.
Because clang_getCursorSpelling returns an empty string for these cursor types, I have implemented functions that get the source range of the operator (only the operator, not the operands), and get the token in the source range.
The problem comes when the expresion involving the operators is inside a macro: the functions return the macro name.
Example:
#define MACRO1(a,b,v,c) case a: v = b*c; break;
static void function(int a)
{
int b;
switch(a)
{
MACRO1(1, 7, b, 6);
case 2: b = 3*4; break;
}
}
In the first 'case', my function returns 'MACRO1' for both operators (= and *). In the second 'case' my function returns '=' and '*'.
Dear libClang developer, can you make that function clang_getCursorSpelling returns the spelling of unary and binary operators (+ - * & = += -= ...)?
Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20191017/0ece184c/attachment.html>
More information about the cfe-dev
mailing list