forked from qt-creator/qt-creator
Another fix for ObjC fast-enum parsing.
This commit is contained in:
@@ -56,7 +56,7 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <QDebug>
|
||||||
CPLUSPLUS_BEGIN_NAMESPACE
|
CPLUSPLUS_BEGIN_NAMESPACE
|
||||||
|
|
||||||
Parser::Parser(TranslationUnit *unit)
|
Parser::Parser(TranslationUnit *unit)
|
||||||
@@ -2189,6 +2189,15 @@ bool Parser::parseForStatement(StatementAST *&node)
|
|||||||
if (parseTypeSpecifier(ast->type_specifiers))
|
if (parseTypeSpecifier(ast->type_specifiers))
|
||||||
parseDeclarator(ast->declarator);
|
parseDeclarator(ast->declarator);
|
||||||
|
|
||||||
|
if ((ast->type_specifiers || ast->declarator) && !peekAtObjCContextKeyword(Token_in)) {
|
||||||
|
// woops, probably parsed too much: "in" got parsed as a declarator. Let's redo it:
|
||||||
|
ast->type_specifiers = 0;
|
||||||
|
ast->declarator = 0;
|
||||||
|
|
||||||
|
rewind(startOfTypeSpecifier);
|
||||||
|
parseDeclarator(ast->declarator);
|
||||||
|
}
|
||||||
|
|
||||||
if (! ast->type_specifiers || ! ast->declarator) {
|
if (! ast->type_specifiers || ! ast->declarator) {
|
||||||
ast->type_specifiers = 0;
|
ast->type_specifiers = 0;
|
||||||
ast->declarator = 0;
|
ast->declarator = 0;
|
||||||
@@ -4635,17 +4644,24 @@ bool Parser::parseObjCTypeQualifiers(unsigned &type_qualifier)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Parser::parseObjCContextKeyword(int kind, unsigned &in_token)
|
bool Parser::peekAtObjCContextKeyword(int kind)
|
||||||
{
|
{
|
||||||
if (LA() != T_IDENTIFIER)
|
if (LA() != T_IDENTIFIER)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Identifier *id = tok().identifier;
|
Identifier *id = tok().identifier;
|
||||||
const int k = classifyObjectiveCTypeQualifiers(id->chars(), id->size());
|
const int k = classifyObjectiveCTypeQualifiers(id->chars(), id->size());
|
||||||
if (k != kind)
|
return k == kind;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Parser::parseObjCContextKeyword(int kind, unsigned &in_token)
|
||||||
|
{
|
||||||
|
if (peekAtObjCContextKeyword(kind)) {
|
||||||
|
in_token = consumeToken();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
return false;
|
return false;
|
||||||
in_token = consumeToken();
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CPLUSPLUS_END_NAMESPACE
|
CPLUSPLUS_END_NAMESPACE
|
||||||
|
@@ -244,6 +244,7 @@ public:
|
|||||||
bool parseObjCSelector(unsigned &selector_token);
|
bool parseObjCSelector(unsigned &selector_token);
|
||||||
bool parseObjCKeywordDeclaration(ObjCSelectorArgumentAST *&argument, ObjCMessageArgumentDeclarationAST *&node);
|
bool parseObjCKeywordDeclaration(ObjCSelectorArgumentAST *&argument, ObjCMessageArgumentDeclarationAST *&node);
|
||||||
bool parseObjCTypeQualifiers(unsigned &type_qualifier);
|
bool parseObjCTypeQualifiers(unsigned &type_qualifier);
|
||||||
|
bool peekAtObjCContextKeyword(int kind);
|
||||||
bool parseObjCContextKeyword(int kind, unsigned &in_token);
|
bool parseObjCContextKeyword(int kind, unsigned &in_token);
|
||||||
|
|
||||||
bool lookAtObjCSelector() const;
|
bool lookAtObjCSelector() const;
|
||||||
|
Reference in New Issue
Block a user