[clazy] [Bug 436606] -std=c++17 mask connect-3arg-lambda check

Evgeniy A. Dushistov bugzilla_noreply at kde.org
Wed May 5 14:18:57 BST 2021


https://bugs.kde.org/show_bug.cgi?id=436606

--- Comment #1 from Evgeniy A. Dushistov <dushistov at mail.ru> ---
Looks like this is expected behavior of clang/libclang:

for code like this:                                                             

#define signals public                                                          
class QObject {                                                                 
signals:                                                                        
        void destroyed();                                                       
public:                                                                         
        template<typename F>                                                    
        static void connect(QObject *, void (QObject::*mf)(void), F f) {}       
        void deleteLater();                                                     
};                                                                              

void test(QObject *o1, QObject *o2)                                             
{                                                                               
    QObject::connect(o1, &QObject::destroyed,                                   
                    [=] { o2->deleteLater(); });                                
}                                                                               

clang dumps different AST.                                                      

In case of -std=c++14 (clang++ -std=c++14 -Xclang -ast-dump -c test.cpp)        
3rd argument (lambda) passed to QObject::connect looks like this:               
CXXConstructExpr 0x5589e3278970 <line:14:21, col:46> '(lambda at
test.cpp:14:21)':'(lambda at test.cpp:14:21)' 'void ((lambda at test.cpp:14:21)
&&) noexcept' elidable                                             
          `-MaterializeTemporaryExpr 0x5589e3275cd0 <col:21, col:46> '(lambda
at test.cpp:14:21)' xvalue                                                      
            `-LambdaExpr                                                        

in case of -std=c++17 lambda looks like this:                                   
   `-LambdaExpr 0x5641f55db880 <line:14:21, col:46> '(lambda at
test.cpp:14:21)'                                                                
        |-CXXRecordDecl 0x5641f55db420 <col:21> col:21 implicit class
definition

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the Unassigned-bugs mailing list