forked from qt-creator/qt-creator
		
	C++: Stop parsing a declaration after two tries
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:Ⓜ️:if_< b:Ⓜ️:bool_<
	(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b:Ⓜ️:int_<70> *) 0)) ==
	 sizeof(defined_)) >, b:Ⓜ️:if_< b:Ⓜ️:bool_<
	(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b:Ⓜ️:int_<71> *) 0)) ==
	 sizeof(defined_)) >, b:Ⓜ️:if_< b:Ⓜ️:bool_<
	(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b:Ⓜ️:int_<72> *) 0)) ==
	 sizeof(defined_)) >, b:Ⓜ️:if_< b:Ⓜ️:bool_<
	(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b:Ⓜ️:int_<73> *) 0)) ==
	 sizeof(defined_)) >, b:Ⓜ️:if_< b:Ⓜ️:bool_<
	(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b:Ⓜ️:int_<74> *) 0)) ==
	 sizeof(defined_)) >, b:Ⓜ️:if_< b:Ⓜ️:bool_<
	(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b:Ⓜ️:int_<75> *) 0)) ==
	 sizeof(defined_)) >, b:Ⓜ️:if_< b:Ⓜ️: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: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
			
			
This commit is contained in:
		
							
								
								
									
										1
									
								
								src/libs/3rdparty/cplusplus/Parser.h
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								src/libs/3rdparty/cplusplus/Parser.h
									
									
									
									
										vendored
									
									
								
							@@ -254,6 +254,7 @@ public:
 | 
			
		||||
    bool parseDesignator(DesignatorAST *&node);
 | 
			
		||||
 | 
			
		||||
    bool skipUntil(int token);
 | 
			
		||||
    void skipUntilAfterSemicolonOrRightBrace();
 | 
			
		||||
    void skipUntilDeclaration();
 | 
			
		||||
    bool skipUntilStatement();
 | 
			
		||||
    bool skip(int l, int r);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user