https://bugs.llvm.org/show_bug.cgi?id=48103

            Bug ID: 48103
           Summary: Incorrect CursorKind for lambda expression
           Product: clang
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: libclang
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]

Created attachment 24140
  --> https://bugs.llvm.org/attachment.cgi?id=24140&action=edit
python script for parsing C++ source and printing AST

this is minimal example

template<class Callable>
void call_func(Callable func);

void foo()
{
  call_func([&]() {});
}

libclang10 identifies lambda parameter as CursorKind.LAMBDA_EXPR but it changed
to CursorKind.OBJ_BOOL_LITERAL_EXPR in libclang11 

This is tree dump for 11 version

./print_ast.py
{'ResourceDir': '/usr/lib64/llvm/11/bin/../../../../lib/clang/11.0.0',
'LibDir': '/usr/lib/llvm/11/lib64'}
None:0 0 l.cpp CursorKind.TRANSLATION_UNIT
l.cpp:2 1 l.cpp.call_func CursorKind.FUNCTION_TEMPLATE
l.cpp:1 2 l.cpp.call_func.Callable CursorKind.TEMPLATE_TYPE_PARAMETER
l.cpp:2 2 l.cpp.call_func.func CursorKind.PARM_DECL
l.cpp:2 3 l.cpp.call_func.func.Callable CursorKind.TYPE_REF
l.cpp:4 1 l.cpp.foo CursorKind.FUNCTION_DECL
l.cpp:5 2 l.cpp.foo. CursorKind.COMPOUND_STMT
l.cpp:6 3 l.cpp.foo.. CursorKind.UNEXPOSED_EXPR
l.cpp:6 4 l.cpp.foo...call_func CursorKind.CALL_EXPR
l.cpp:6 5 l.cpp.foo...call_func.call_func CursorKind.UNEXPOSED_EXPR
l.cpp:6 6 l.cpp.foo...call_func.call_func.call_func CursorKind.DECL_REF_EXPR
l.cpp:6 5 l.cpp.foo...call_func. CursorKind.CALL_EXPR
l.cpp:6 6 l.cpp.foo...call_func.. CursorKind.UNEXPOSED_EXPR
l.cpp:6 7 l.cpp.foo...call_func... CursorKind.OBJ_BOOL_LITERAL_EXPR
l.cpp:6 8 l.cpp.foo...call_func.... CursorKind.COMPOUND_STMT


This is for 10 

./print_ast.py  
{'ResourceDir': '/usr/lib64/llvm/10/bin/../../../../lib/clang/10.0.1',
'LibDir': '/usr/lib/llvm/10/lib64'}
None:0 0 l.cpp CursorKind.TRANSLATION_UNIT
l.cpp:2 1 l.cpp.call_func CursorKind.FUNCTION_TEMPLATE
l.cpp:1 2 l.cpp.call_func.Callable CursorKind.TEMPLATE_TYPE_PARAMETER
l.cpp:2 2 l.cpp.call_func.func CursorKind.PARM_DECL
l.cpp:2 3 l.cpp.call_func.func.Callable CursorKind.TYPE_REF
l.cpp:4 1 l.cpp.foo CursorKind.FUNCTION_DECL
l.cpp:5 2 l.cpp.foo. CursorKind.COMPOUND_STMT
l.cpp:6 3 l.cpp.foo.. CursorKind.UNEXPOSED_EXPR
l.cpp:6 4 l.cpp.foo...call_func CursorKind.CALL_EXPR
l.cpp:6 5 l.cpp.foo...call_func.call_func CursorKind.UNEXPOSED_EXPR
l.cpp:6 6 l.cpp.foo...call_func.call_func.call_func CursorKind.DECL_REF_EXPR
l.cpp:6 5 l.cpp.foo...call_func. CursorKind.CALL_EXPR
l.cpp:6 6 l.cpp.foo...call_func.. CursorKind.UNEXPOSED_EXPR
l.cpp:6 7 l.cpp.foo...call_func... CursorKind.LAMBDA_EXPR
l.cpp:6 8 l.cpp.foo...call_func.... CursorKind.COMPOUND_STMT

Notice how child of CALL_EXPR.UNEXPOSED_EXPR is changed in new version. 
There is no way anymore to detect lambda call in AST

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to