• Nikolai Kosjar's avatar
    C++: Stop parsing a declaration after two tries · 78ab287f
    Nikolai Kosjar authored
    
    
    If we fail to parse a declaration, we rewind, eat the token and look for the
    next token that might be a good candidate for a declaration start (e.g. an
    identifier). This becomes cpu and memory expensive with super long and invalid
    expressions like
    
        typedef b::m::if_< b::m::bool_<
    	(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b::m::int_<70> *) 0)) ==
    	 sizeof(defined_)) >, b::m::if_< b::m::bool_<
    	(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b::m::int_<71> *) 0)) ==
    	 sizeof(defined_)) >, b::m::if_< b::m::bool_<
    	(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b::m::int_<72> *) 0)) ==
    	 sizeof(defined_)) >, b::m::if_< b::m::bool_<
    	(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b::m::int_<73> *) 0)) ==
    	 sizeof(defined_)) >, b::m::if_< b::m::bool_<
    	(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b::m::int_<74> *) 0)) ==
    	 sizeof(defined_)) >, b::m::if_< b::m::bool_<
    	(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b::m::int_<75> *) 0)) ==
    	 sizeof(defined_)) >, b::m::if_< b::m::bool_<
    	// ...some more crazy lines like this
    
    Therefore, stop trying after two failures by looking for the next semicolon or
    closing curly brace.
    
    Task-number: QTCREATORBUG-12890
    Change-Id: I6637daeb840dd549d669080775228fa91fc932eb
    Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@theqtcompany.com>
    78ab287f
Parser.cpp 208 KB