forked from qt-creator/qt-creator
C++: Remove workaround for crashing if parsing invalid code
This reverts the changes
commit beac7b9539
C++: Fix highlighting after "invalid code"
commit 78ab287fc6
C++: Stop parsing a declaration after two tries
which were a work around for QTCREATORBUG-12890.
A follow-up patch provides a proper fix.
Task-number: QTCREATORBUG-12890
Change-Id: I2650a8e41c8ff1180cad9f069e463fc51bd2f1b1
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
This commit is contained in:
33
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
33
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
@@ -265,13 +265,12 @@ inline void debugPrintCheckCache(bool) {}
|
||||
return true; \
|
||||
}
|
||||
|
||||
Parser::Parser(TranslationUnit *unit, int retryParseDeclarationLimit)
|
||||
Parser::Parser(TranslationUnit *unit)
|
||||
: _translationUnit(unit),
|
||||
_control(unit->control()),
|
||||
_pool(unit->memoryPool()),
|
||||
_languageFeatures(unit->languageFeatures()),
|
||||
_tokenIndex(1),
|
||||
_retryParseDeclarationLimit(retryParseDeclarationLimit),
|
||||
_templateArguments(0),
|
||||
_inFunctionBody(false),
|
||||
_inExpressionStatement(false),
|
||||
@@ -311,20 +310,6 @@ bool Parser::skipUntil(int token)
|
||||
return false;
|
||||
}
|
||||
|
||||
void Parser::skipUntilAfterSemicolonOrRightBrace()
|
||||
{
|
||||
while (int tk = LA()) {
|
||||
switch (tk) {
|
||||
case T_SEMICOLON:
|
||||
case T_RBRACE:
|
||||
consumeToken();
|
||||
return;
|
||||
default:
|
||||
consumeToken();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Parser::skipUntilDeclaration()
|
||||
{
|
||||
for (; ; consumeToken()) {
|
||||
@@ -641,25 +626,19 @@ bool Parser::parseTranslationUnit(TranslationUnitAST *&node)
|
||||
TranslationUnitAST *ast = new (_pool) TranslationUnitAST;
|
||||
DeclarationListAST **decl = &ast->declaration_list;
|
||||
|
||||
int declarationsInRowFailedToParse = 0;
|
||||
|
||||
while (LA()) {
|
||||
unsigned start_declaration = cursor();
|
||||
|
||||
DeclarationAST *declaration = 0;
|
||||
|
||||
if (parseDeclaration(declaration)) {
|
||||
declarationsInRowFailedToParse = 0;
|
||||
*decl = new (_pool) DeclarationListAST;
|
||||
(*decl)->value = declaration;
|
||||
decl = &(*decl)->next;
|
||||
} else {
|
||||
error(start_declaration, "expected a declaration");
|
||||
rewind(start_declaration + 1);
|
||||
if (++declarationsInRowFailedToParse == _retryParseDeclarationLimit)
|
||||
skipUntilAfterSemicolonOrRightBrace();
|
||||
else
|
||||
skipUntilDeclaration();
|
||||
skipUntilDeclaration();
|
||||
}
|
||||
|
||||
|
||||
@@ -808,8 +787,6 @@ bool Parser::parseLinkageBody(DeclarationAST *&node)
|
||||
ast->lbrace_token = consumeToken();
|
||||
DeclarationListAST **declaration_ptr = &ast->declaration_list;
|
||||
|
||||
int declarationsInRowFailedToParse = 0;
|
||||
|
||||
while (int tk = LA()) {
|
||||
if (tk == T_RBRACE)
|
||||
break;
|
||||
@@ -817,17 +794,13 @@ bool Parser::parseLinkageBody(DeclarationAST *&node)
|
||||
unsigned start_declaration = cursor();
|
||||
DeclarationAST *declaration = 0;
|
||||
if (parseDeclaration(declaration)) {
|
||||
declarationsInRowFailedToParse = 0;
|
||||
*declaration_ptr = new (_pool) DeclarationListAST;
|
||||
(*declaration_ptr)->value = declaration;
|
||||
declaration_ptr = &(*declaration_ptr)->next;
|
||||
} else {
|
||||
error(start_declaration, "expected a declaration");
|
||||
rewind(start_declaration + 1);
|
||||
if (++declarationsInRowFailedToParse == _retryParseDeclarationLimit)
|
||||
skipUntilAfterSemicolonOrRightBrace();
|
||||
else
|
||||
skipUntilDeclaration();
|
||||
skipUntilDeclaration();
|
||||
}
|
||||
|
||||
_templateArgumentList.clear();
|
||||
|
||||
Reference in New Issue
Block a user