forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/3.2'
Conflicts: qtcreator.pri qtcreator.qbs src/plugins/android/androidglobal.h Change-Id: I3367bf2ea47c088989175dddeed2210294346f4c
This commit is contained in:
42
src/libs/3rdparty/cplusplus/AST.cpp
vendored
42
src/libs/3rdparty/cplusplus/AST.cpp
vendored
@@ -68,7 +68,7 @@ bool AST::match(AST *pattern, ASTMatcher *matcher)
|
||||
return match0(pattern, matcher);
|
||||
}
|
||||
|
||||
unsigned AttributeSpecifierAST::firstToken() const
|
||||
unsigned GnuAttributeSpecifierAST::firstToken() const
|
||||
{
|
||||
return attribute_token;
|
||||
}
|
||||
@@ -242,7 +242,7 @@ unsigned AsmDefinitionAST::lastToken() const
|
||||
}
|
||||
|
||||
/** \generated */
|
||||
unsigned AttributeAST::firstToken() const
|
||||
unsigned GnuAttributeAST::firstToken() const
|
||||
{
|
||||
if (identifier_token)
|
||||
return identifier_token;
|
||||
@@ -259,7 +259,7 @@ unsigned AttributeAST::firstToken() const
|
||||
}
|
||||
|
||||
/** \generated */
|
||||
unsigned AttributeAST::lastToken() const
|
||||
unsigned GnuAttributeAST::lastToken() const
|
||||
{
|
||||
if (rparen_token)
|
||||
return rparen_token + 1;
|
||||
@@ -4194,7 +4194,7 @@ unsigned WhileStatementAST::lastToken() const
|
||||
}
|
||||
|
||||
/** \generated */
|
||||
unsigned AttributeSpecifierAST::lastToken() const
|
||||
unsigned GnuAttributeSpecifierAST::lastToken() const
|
||||
{
|
||||
if (second_rparen_token)
|
||||
return second_rparen_token + 1;
|
||||
@@ -4524,3 +4524,37 @@ unsigned DotDesignatorAST::lastToken() const
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** \generated */
|
||||
unsigned AlignmentSpecifierAST::firstToken() const
|
||||
{
|
||||
if (align_token)
|
||||
return align_token;
|
||||
if (lparen_token)
|
||||
return lparen_token;
|
||||
if (typeIdExprOrAlignmentExpr)
|
||||
if (unsigned candidate = typeIdExprOrAlignmentExpr->firstToken())
|
||||
return candidate;
|
||||
if (ellipses_token)
|
||||
return ellipses_token;
|
||||
if (rparen_token)
|
||||
return rparen_token;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** \generated */
|
||||
unsigned AlignmentSpecifierAST::lastToken() const
|
||||
{
|
||||
if (rparen_token)
|
||||
return rparen_token + 1;
|
||||
if (ellipses_token)
|
||||
return ellipses_token + 1;
|
||||
if (typeIdExprOrAlignmentExpr)
|
||||
if (unsigned candidate = typeIdExprOrAlignmentExpr->lastToken())
|
||||
return candidate;
|
||||
if (lparen_token)
|
||||
return lparen_token + 1;
|
||||
if (align_token)
|
||||
return align_token + 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
62
src/libs/3rdparty/cplusplus/AST.h
vendored
62
src/libs/3rdparty/cplusplus/AST.h
vendored
@@ -126,13 +126,13 @@ public:
|
||||
|
||||
virtual AccessDeclarationAST *asAccessDeclaration() { return 0; }
|
||||
virtual AliasDeclarationAST *asAliasDeclaration() { return 0; }
|
||||
virtual AlignmentSpecifierAST *asAlignmentSpecifier() { return 0; }
|
||||
virtual AlignofExpressionAST *asAlignofExpression() { return 0; }
|
||||
virtual AnonymousNameAST *asAnonymousName() { return 0; }
|
||||
virtual ArrayAccessAST *asArrayAccess() { return 0; }
|
||||
virtual ArrayDeclaratorAST *asArrayDeclarator() { return 0; }
|
||||
virtual ArrayInitializerAST *asArrayInitializer() { return 0; }
|
||||
virtual AsmDefinitionAST *asAsmDefinition() { return 0; }
|
||||
virtual AttributeAST *asAttribute() { return 0; }
|
||||
virtual AttributeSpecifierAST *asAttributeSpecifier() { return 0; }
|
||||
virtual BaseSpecifierAST *asBaseSpecifier() { return 0; }
|
||||
virtual BinaryExpressionAST *asBinaryExpression() { return 0; }
|
||||
@@ -182,6 +182,8 @@ public:
|
||||
virtual ForeachStatementAST *asForeachStatement() { return 0; }
|
||||
virtual FunctionDeclaratorAST *asFunctionDeclarator() { return 0; }
|
||||
virtual FunctionDefinitionAST *asFunctionDefinition() { return 0; }
|
||||
virtual GnuAttributeAST *asGnuAttribute() { return 0; }
|
||||
virtual GnuAttributeSpecifierAST *asGnuAttributeSpecifier() { return 0; }
|
||||
virtual GotoStatementAST *asGotoStatement() { return 0; }
|
||||
virtual IdExpressionAST *asIdExpression() { return 0; }
|
||||
virtual IfStatementAST *asIfStatement() { return 0; }
|
||||
@@ -462,16 +464,58 @@ protected:
|
||||
|
||||
class CPLUSPLUS_EXPORT AttributeSpecifierAST: public SpecifierAST
|
||||
{
|
||||
public:
|
||||
AttributeSpecifierAST()
|
||||
{}
|
||||
|
||||
virtual AttributeSpecifierAST *asAttributeSpecifier() { return this; }
|
||||
|
||||
virtual AttributeSpecifierAST *clone(MemoryPool *pool) const = 0;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT AlignmentSpecifierAST: public AttributeSpecifierAST
|
||||
{
|
||||
public:
|
||||
unsigned align_token;
|
||||
unsigned lparen_token;
|
||||
ExpressionAST *typeIdExprOrAlignmentExpr;
|
||||
unsigned ellipses_token;
|
||||
unsigned rparen_token;
|
||||
|
||||
public:
|
||||
AlignmentSpecifierAST()
|
||||
: align_token(0)
|
||||
, lparen_token(0)
|
||||
, typeIdExprOrAlignmentExpr(0)
|
||||
, ellipses_token(0)
|
||||
, rparen_token(0)
|
||||
{}
|
||||
|
||||
virtual AlignmentSpecifierAST *asAlignmentSpecifier() { return this; }
|
||||
|
||||
virtual unsigned firstToken() const;
|
||||
virtual unsigned lastToken() const;
|
||||
|
||||
virtual AlignmentSpecifierAST *clone(MemoryPool *pool) const;
|
||||
|
||||
protected:
|
||||
virtual void accept0(ASTVisitor *visitor);
|
||||
virtual bool match0(AST *, ASTMatcher *);
|
||||
};
|
||||
|
||||
|
||||
class CPLUSPLUS_EXPORT GnuAttributeSpecifierAST: public AttributeSpecifierAST
|
||||
{
|
||||
public:
|
||||
unsigned attribute_token;
|
||||
unsigned first_lparen_token;
|
||||
unsigned second_lparen_token;
|
||||
AttributeListAST *attribute_list;
|
||||
GnuAttributeListAST *attribute_list;
|
||||
unsigned first_rparen_token;
|
||||
unsigned second_rparen_token;
|
||||
|
||||
public:
|
||||
AttributeSpecifierAST()
|
||||
GnuAttributeSpecifierAST()
|
||||
: attribute_token(0)
|
||||
, first_lparen_token(0)
|
||||
, second_lparen_token(0)
|
||||
@@ -480,19 +524,19 @@ public:
|
||||
, second_rparen_token(0)
|
||||
{}
|
||||
|
||||
virtual AttributeSpecifierAST *asAttributeSpecifier() { return this; }
|
||||
virtual GnuAttributeSpecifierAST *asGnuAttributeSpecifier() { return this; }
|
||||
|
||||
virtual unsigned firstToken() const;
|
||||
virtual unsigned lastToken() const;
|
||||
|
||||
virtual AttributeSpecifierAST *clone(MemoryPool *pool) const;
|
||||
virtual GnuAttributeSpecifierAST *clone(MemoryPool *pool) const;
|
||||
|
||||
protected:
|
||||
virtual void accept0(ASTVisitor *visitor);
|
||||
virtual bool match0(AST *, ASTMatcher *);
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT AttributeAST: public AST
|
||||
class CPLUSPLUS_EXPORT GnuAttributeAST: public AST
|
||||
{
|
||||
public:
|
||||
unsigned identifier_token;
|
||||
@@ -502,7 +546,7 @@ public:
|
||||
unsigned rparen_token;
|
||||
|
||||
public:
|
||||
AttributeAST()
|
||||
GnuAttributeAST()
|
||||
: identifier_token(0)
|
||||
, lparen_token(0)
|
||||
, tag_token(0)
|
||||
@@ -510,12 +554,12 @@ public:
|
||||
, rparen_token(0)
|
||||
{}
|
||||
|
||||
virtual AttributeAST *asAttribute() { return this; }
|
||||
virtual GnuAttributeAST *asGnuAttribute() { return this; }
|
||||
|
||||
virtual unsigned firstToken() const;
|
||||
virtual unsigned lastToken() const;
|
||||
|
||||
virtual AttributeAST *clone(MemoryPool *pool) const;
|
||||
virtual GnuAttributeAST *clone(MemoryPool *pool) const;
|
||||
|
||||
protected:
|
||||
virtual void accept0(ASTVisitor *visitor);
|
||||
|
||||
24
src/libs/3rdparty/cplusplus/ASTClone.cpp
vendored
24
src/libs/3rdparty/cplusplus/ASTClone.cpp
vendored
@@ -55,23 +55,35 @@ SimpleSpecifierAST *SimpleSpecifierAST::clone(MemoryPool *pool) const
|
||||
return ast;
|
||||
}
|
||||
|
||||
AttributeSpecifierAST *AttributeSpecifierAST::clone(MemoryPool *pool) const
|
||||
AlignmentSpecifierAST *AlignmentSpecifierAST::clone(MemoryPool *pool) const
|
||||
{
|
||||
AttributeSpecifierAST *ast = new (pool) AttributeSpecifierAST;
|
||||
AlignmentSpecifierAST *ast = new (pool) AlignmentSpecifierAST;
|
||||
ast->align_token = align_token;
|
||||
ast->lparen_token = lparen_token;
|
||||
if (typeIdExprOrAlignmentExpr)
|
||||
ast->typeIdExprOrAlignmentExpr = typeIdExprOrAlignmentExpr->clone(pool);
|
||||
ast->ellipses_token = ellipses_token;
|
||||
ast->rparen_token = rparen_token;
|
||||
return ast;
|
||||
}
|
||||
|
||||
GnuAttributeSpecifierAST *GnuAttributeSpecifierAST::clone(MemoryPool *pool) const
|
||||
{
|
||||
GnuAttributeSpecifierAST *ast = new (pool) GnuAttributeSpecifierAST;
|
||||
ast->attribute_token = attribute_token;
|
||||
ast->first_lparen_token = first_lparen_token;
|
||||
ast->second_lparen_token = second_lparen_token;
|
||||
for (AttributeListAST *iter = attribute_list, **ast_iter = &ast->attribute_list;
|
||||
for (GnuAttributeListAST *iter = attribute_list, **ast_iter = &ast->attribute_list;
|
||||
iter; iter = iter->next, ast_iter = &(*ast_iter)->next)
|
||||
*ast_iter = new (pool) AttributeListAST((iter->value) ? iter->value->clone(pool) : 0);
|
||||
*ast_iter = new (pool) GnuAttributeListAST((iter->value) ? iter->value->clone(pool) : 0);
|
||||
ast->first_rparen_token = first_rparen_token;
|
||||
ast->second_rparen_token = second_rparen_token;
|
||||
return ast;
|
||||
}
|
||||
|
||||
AttributeAST *AttributeAST::clone(MemoryPool *pool) const
|
||||
GnuAttributeAST *GnuAttributeAST::clone(MemoryPool *pool) const
|
||||
{
|
||||
AttributeAST *ast = new (pool) AttributeAST;
|
||||
GnuAttributeAST *ast = new (pool) GnuAttributeAST;
|
||||
ast->identifier_token = identifier_token;
|
||||
ast->lparen_token = lparen_token;
|
||||
ast->tag_token = tag_token;
|
||||
|
||||
16
src/libs/3rdparty/cplusplus/ASTMatch0.cpp
vendored
16
src/libs/3rdparty/cplusplus/ASTMatch0.cpp
vendored
@@ -56,17 +56,25 @@ bool SimpleSpecifierAST::match0(AST *pattern, ASTMatcher *matcher)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AttributeSpecifierAST::match0(AST *pattern, ASTMatcher *matcher)
|
||||
bool AlignmentSpecifierAST::match0(AST *pattern, ASTMatcher *matcher)
|
||||
{
|
||||
if (AttributeSpecifierAST *_other = pattern->asAttributeSpecifier())
|
||||
if (AlignmentSpecifierAST *_other = pattern->asAlignmentSpecifier())
|
||||
return matcher->match(this, _other);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AttributeAST::match0(AST *pattern, ASTMatcher *matcher)
|
||||
bool GnuAttributeSpecifierAST::match0(AST *pattern, ASTMatcher *matcher)
|
||||
{
|
||||
if (AttributeAST *_other = pattern->asAttribute())
|
||||
if (GnuAttributeSpecifierAST *_other = pattern->asGnuAttributeSpecifier())
|
||||
return matcher->match(this, _other);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GnuAttributeAST::match0(AST *pattern, ASTMatcher *matcher)
|
||||
{
|
||||
if (GnuAttributeAST *_other = pattern->asGnuAttribute())
|
||||
return matcher->match(this, _other);
|
||||
|
||||
return false;
|
||||
|
||||
25
src/libs/3rdparty/cplusplus/ASTMatcher.cpp
vendored
25
src/libs/3rdparty/cplusplus/ASTMatcher.cpp
vendored
@@ -73,7 +73,28 @@ bool ASTMatcher::match(SimpleSpecifierAST *node, SimpleSpecifierAST *pattern)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ASTMatcher::match(AttributeSpecifierAST *node, AttributeSpecifierAST *pattern)
|
||||
bool ASTMatcher::match(AlignmentSpecifierAST *node, AlignmentSpecifierAST *pattern)
|
||||
{
|
||||
(void) node;
|
||||
(void) pattern;
|
||||
|
||||
pattern->align_token = node->align_token;
|
||||
|
||||
pattern->lparen_token = node->lparen_token;
|
||||
|
||||
if (! pattern->typeIdExprOrAlignmentExpr)
|
||||
pattern->typeIdExprOrAlignmentExpr = node->typeIdExprOrAlignmentExpr;
|
||||
else if (! AST::match(node->typeIdExprOrAlignmentExpr, pattern->typeIdExprOrAlignmentExpr, this))
|
||||
return false;
|
||||
|
||||
pattern->ellipses_token = node->ellipses_token;
|
||||
|
||||
pattern->rparen_token = node->rparen_token;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ASTMatcher::match(GnuAttributeSpecifierAST *node, GnuAttributeSpecifierAST *pattern)
|
||||
{
|
||||
(void) node;
|
||||
(void) pattern;
|
||||
@@ -96,7 +117,7 @@ bool ASTMatcher::match(AttributeSpecifierAST *node, AttributeSpecifierAST *patte
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ASTMatcher::match(AttributeAST *node, AttributeAST *pattern)
|
||||
bool ASTMatcher::match(GnuAttributeAST *node, GnuAttributeAST *pattern)
|
||||
{
|
||||
(void) node;
|
||||
(void) pattern;
|
||||
|
||||
5
src/libs/3rdparty/cplusplus/ASTMatcher.h
vendored
5
src/libs/3rdparty/cplusplus/ASTMatcher.h
vendored
@@ -33,14 +33,13 @@ public:
|
||||
|
||||
virtual bool match(AccessDeclarationAST *node, AccessDeclarationAST *pattern);
|
||||
virtual bool match(AliasDeclarationAST *node, AliasDeclarationAST *pattern);
|
||||
virtual bool match(AlignmentSpecifierAST *node, AlignmentSpecifierAST *pattern);
|
||||
virtual bool match(AlignofExpressionAST *node, AlignofExpressionAST *pattern);
|
||||
virtual bool match(AnonymousNameAST *node, AnonymousNameAST *pattern);
|
||||
virtual bool match(ArrayAccessAST *node, ArrayAccessAST *pattern);
|
||||
virtual bool match(ArrayDeclaratorAST *node, ArrayDeclaratorAST *pattern);
|
||||
virtual bool match(ArrayInitializerAST *node, ArrayInitializerAST *pattern);
|
||||
virtual bool match(AsmDefinitionAST *node, AsmDefinitionAST *pattern);
|
||||
virtual bool match(AttributeAST *node, AttributeAST *pattern);
|
||||
virtual bool match(AttributeSpecifierAST *node, AttributeSpecifierAST *pattern);
|
||||
virtual bool match(BaseSpecifierAST *node, BaseSpecifierAST *pattern);
|
||||
virtual bool match(BinaryExpressionAST *node, BinaryExpressionAST *pattern);
|
||||
virtual bool match(BoolLiteralAST *node, BoolLiteralAST *pattern);
|
||||
@@ -84,6 +83,8 @@ public:
|
||||
virtual bool match(ForeachStatementAST *node, ForeachStatementAST *pattern);
|
||||
virtual bool match(FunctionDeclaratorAST *node, FunctionDeclaratorAST *pattern);
|
||||
virtual bool match(FunctionDefinitionAST *node, FunctionDefinitionAST *pattern);
|
||||
virtual bool match(GnuAttributeAST *node, GnuAttributeAST *pattern);
|
||||
virtual bool match(GnuAttributeSpecifierAST *node, GnuAttributeSpecifierAST *pattern);
|
||||
virtual bool match(GotoStatementAST *node, GotoStatementAST *pattern);
|
||||
virtual bool match(IdExpressionAST *node, IdExpressionAST *pattern);
|
||||
virtual bool match(IfStatementAST *node, IfStatementAST *pattern);
|
||||
|
||||
31
src/libs/3rdparty/cplusplus/ASTPatternBuilder.h
vendored
31
src/libs/3rdparty/cplusplus/ASTPatternBuilder.h
vendored
@@ -63,16 +63,23 @@ public:
|
||||
return __ast;
|
||||
}
|
||||
|
||||
AttributeSpecifierAST *AttributeSpecifier(AttributeListAST *attribute_list = 0)
|
||||
AlignmentSpecifierAST *AlignmentSpecifier(ExpressionAST *typeIdExprOrAlignmentExpr = 0)
|
||||
{
|
||||
AttributeSpecifierAST *__ast = new (&pool) AttributeSpecifierAST;
|
||||
AlignmentSpecifierAST *__ast = new (&pool) AlignmentSpecifierAST;
|
||||
__ast->typeIdExprOrAlignmentExpr = typeIdExprOrAlignmentExpr;
|
||||
return __ast;
|
||||
}
|
||||
|
||||
GnuAttributeSpecifierAST *GnuAttributeSpecifier(GnuAttributeListAST *attribute_list = 0)
|
||||
{
|
||||
GnuAttributeSpecifierAST *__ast = new (&pool) GnuAttributeSpecifierAST;
|
||||
__ast->attribute_list = attribute_list;
|
||||
return __ast;
|
||||
}
|
||||
|
||||
AttributeAST *Attribute(ExpressionListAST *expression_list = 0)
|
||||
GnuAttributeAST *GnuAttribute(ExpressionListAST *expression_list = 0)
|
||||
{
|
||||
AttributeAST *__ast = new (&pool) AttributeAST;
|
||||
GnuAttributeAST *__ast = new (&pool) GnuAttributeAST;
|
||||
__ast->expression_list = expression_list;
|
||||
return __ast;
|
||||
}
|
||||
@@ -1168,14 +1175,6 @@ public:
|
||||
return __ast;
|
||||
}
|
||||
|
||||
AttributeListAST *AttributeList(AttributeAST *value, AttributeListAST *next = 0)
|
||||
{
|
||||
AttributeListAST *__list = new (&pool) AttributeListAST;
|
||||
__list->next = next;
|
||||
__list->value = value;
|
||||
return __list;
|
||||
}
|
||||
|
||||
BaseSpecifierListAST *BaseSpecifierList(BaseSpecifierAST *value, BaseSpecifierListAST *next = 0)
|
||||
{
|
||||
BaseSpecifierListAST *__list = new (&pool) BaseSpecifierListAST;
|
||||
@@ -1240,6 +1239,14 @@ public:
|
||||
return __list;
|
||||
}
|
||||
|
||||
GnuAttributeListAST *GnuAttributeList(GnuAttributeAST *value, GnuAttributeListAST *next = 0)
|
||||
{
|
||||
GnuAttributeListAST *__list = new (&pool) GnuAttributeListAST;
|
||||
__list->next = next;
|
||||
__list->value = value;
|
||||
return __list;
|
||||
}
|
||||
|
||||
MemInitializerListAST *MemInitializerList(MemInitializerAST *value, MemInitializerListAST *next = 0)
|
||||
{
|
||||
MemInitializerListAST *__list = new (&pool) MemInitializerListAST;
|
||||
|
||||
12
src/libs/3rdparty/cplusplus/ASTVisit.cpp
vendored
12
src/libs/3rdparty/cplusplus/ASTVisit.cpp
vendored
@@ -54,7 +54,15 @@ void SimpleSpecifierAST::accept0(ASTVisitor *visitor)
|
||||
visitor->endVisit(this);
|
||||
}
|
||||
|
||||
void AttributeSpecifierAST::accept0(ASTVisitor *visitor)
|
||||
void AlignmentSpecifierAST::accept0(ASTVisitor *visitor)
|
||||
{
|
||||
if (visitor->visit(this)) {
|
||||
accept(typeIdExprOrAlignmentExpr, visitor);
|
||||
}
|
||||
visitor->endVisit(this);
|
||||
}
|
||||
|
||||
void GnuAttributeSpecifierAST::accept0(ASTVisitor *visitor)
|
||||
{
|
||||
if (visitor->visit(this)) {
|
||||
accept(attribute_list, visitor);
|
||||
@@ -62,7 +70,7 @@ void AttributeSpecifierAST::accept0(ASTVisitor *visitor)
|
||||
visitor->endVisit(this);
|
||||
}
|
||||
|
||||
void AttributeAST::accept0(ASTVisitor *visitor)
|
||||
void GnuAttributeAST::accept0(ASTVisitor *visitor)
|
||||
{
|
||||
if (visitor->visit(this)) {
|
||||
accept(expression_list, visitor);
|
||||
|
||||
10
src/libs/3rdparty/cplusplus/ASTVisitor.h
vendored
10
src/libs/3rdparty/cplusplus/ASTVisitor.h
vendored
@@ -75,14 +75,13 @@ public:
|
||||
|
||||
virtual bool visit(AccessDeclarationAST *) { return true; }
|
||||
virtual bool visit(AliasDeclarationAST *) { return true; }
|
||||
virtual bool visit(AlignmentSpecifierAST *) { return true; }
|
||||
virtual bool visit(AlignofExpressionAST *) { return true; }
|
||||
virtual bool visit(AnonymousNameAST *) { return true; }
|
||||
virtual bool visit(ArrayAccessAST *) { return true; }
|
||||
virtual bool visit(ArrayDeclaratorAST *) { return true; }
|
||||
virtual bool visit(ArrayInitializerAST *) { return true; }
|
||||
virtual bool visit(AsmDefinitionAST *) { return true; }
|
||||
virtual bool visit(AttributeAST *) { return true; }
|
||||
virtual bool visit(AttributeSpecifierAST *) { return true; }
|
||||
virtual bool visit(BaseSpecifierAST *) { return true; }
|
||||
virtual bool visit(BinaryExpressionAST *) { return true; }
|
||||
virtual bool visit(BoolLiteralAST *) { return true; }
|
||||
@@ -126,6 +125,8 @@ public:
|
||||
virtual bool visit(ForeachStatementAST *) { return true; }
|
||||
virtual bool visit(FunctionDeclaratorAST *) { return true; }
|
||||
virtual bool visit(FunctionDefinitionAST *) { return true; }
|
||||
virtual bool visit(GnuAttributeAST *) { return true; }
|
||||
virtual bool visit(GnuAttributeSpecifierAST *) { return true; }
|
||||
virtual bool visit(GotoStatementAST *) { return true; }
|
||||
virtual bool visit(IdExpressionAST *) { return true; }
|
||||
virtual bool visit(IfStatementAST *) { return true; }
|
||||
@@ -224,14 +225,13 @@ public:
|
||||
|
||||
virtual void endVisit(AccessDeclarationAST *) {}
|
||||
virtual void endVisit(AliasDeclarationAST *) {}
|
||||
virtual void endVisit(AlignmentSpecifierAST *) {}
|
||||
virtual void endVisit(AlignofExpressionAST *) {}
|
||||
virtual void endVisit(AnonymousNameAST *) {}
|
||||
virtual void endVisit(ArrayAccessAST *) {}
|
||||
virtual void endVisit(ArrayDeclaratorAST *) {}
|
||||
virtual void endVisit(ArrayInitializerAST *) {}
|
||||
virtual void endVisit(AsmDefinitionAST *) {}
|
||||
virtual void endVisit(AttributeAST *) {}
|
||||
virtual void endVisit(AttributeSpecifierAST *) {}
|
||||
virtual void endVisit(BaseSpecifierAST *) {}
|
||||
virtual void endVisit(BinaryExpressionAST *) {}
|
||||
virtual void endVisit(BoolLiteralAST *) {}
|
||||
@@ -275,6 +275,8 @@ public:
|
||||
virtual void endVisit(ForeachStatementAST *) {}
|
||||
virtual void endVisit(FunctionDeclaratorAST *) {}
|
||||
virtual void endVisit(FunctionDefinitionAST *) {}
|
||||
virtual void endVisit(GnuAttributeAST *) {}
|
||||
virtual void endVisit(GnuAttributeSpecifierAST *) {}
|
||||
virtual void endVisit(GotoStatementAST *) {}
|
||||
virtual void endVisit(IdExpressionAST *) {}
|
||||
virtual void endVisit(IfStatementAST *) {}
|
||||
|
||||
6
src/libs/3rdparty/cplusplus/ASTfwd.h
vendored
6
src/libs/3rdparty/cplusplus/ASTfwd.h
vendored
@@ -33,13 +33,13 @@ class ASTMatcher;
|
||||
|
||||
class AccessDeclarationAST;
|
||||
class AliasDeclarationAST;
|
||||
class AlignmentSpecifierAST;
|
||||
class AlignofExpressionAST;
|
||||
class AnonymousNameAST;
|
||||
class ArrayAccessAST;
|
||||
class ArrayDeclaratorAST;
|
||||
class ArrayInitializerAST;
|
||||
class AsmDefinitionAST;
|
||||
class AttributeAST;
|
||||
class AttributeSpecifierAST;
|
||||
class BaseSpecifierAST;
|
||||
class BinaryExpressionAST;
|
||||
@@ -89,6 +89,8 @@ class ForStatementAST;
|
||||
class ForeachStatementAST;
|
||||
class FunctionDeclaratorAST;
|
||||
class FunctionDefinitionAST;
|
||||
class GnuAttributeAST;
|
||||
class GnuAttributeSpecifierAST;
|
||||
class GotoStatementAST;
|
||||
class IdExpressionAST;
|
||||
class IfStatementAST;
|
||||
@@ -201,7 +203,7 @@ typedef List<MemInitializerAST *> MemInitializerListAST;
|
||||
typedef List<NewArrayDeclaratorAST *> NewArrayDeclaratorListAST;
|
||||
typedef List<PostfixAST *> PostfixListAST;
|
||||
typedef List<PostfixDeclaratorAST *> PostfixDeclaratorListAST;
|
||||
typedef List<AttributeAST *> AttributeListAST;
|
||||
typedef List<GnuAttributeAST *> GnuAttributeListAST;
|
||||
typedef List<NestedNameSpecifierAST *> NestedNameSpecifierListAST;
|
||||
typedef List<CatchClauseAST *> CatchClauseListAST;
|
||||
typedef List<PtrOperatorAST *> PtrOperatorListAST;
|
||||
|
||||
18
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
18
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
@@ -303,14 +303,14 @@ const Name *Bind::objCSelectorArgument(ObjCSelectorArgumentAST *ast, bool *hasAr
|
||||
return identifier(ast->name_token);
|
||||
}
|
||||
|
||||
bool Bind::visit(AttributeAST *ast)
|
||||
bool Bind::visit(GnuAttributeAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
void Bind::attribute(AttributeAST *ast)
|
||||
void Bind::attribute(GnuAttributeAST *ast)
|
||||
{
|
||||
if (! ast)
|
||||
return;
|
||||
@@ -2567,6 +2567,8 @@ bool Bind::visit(ObjCMethodDeclarationAST *ast)
|
||||
this->statement(ast->function_body);
|
||||
(void) switchScope(previousScope);
|
||||
_scope->addMember(method);
|
||||
} else if (method) {
|
||||
_scope->addMember(method);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -2902,12 +2904,20 @@ bool Bind::visit(SimpleSpecifierAST *ast)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Bind::visit(AttributeSpecifierAST *ast)
|
||||
bool Bind::visit(AlignmentSpecifierAST *ast)
|
||||
{
|
||||
// Prevent visiting the type-id or alignment expression from changing the currently
|
||||
// calculated type:
|
||||
expression(ast->typeIdExprOrAlignmentExpr);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Bind::visit(GnuAttributeSpecifierAST *ast)
|
||||
{
|
||||
// unsigned attribute_token = ast->attribute_token;
|
||||
// unsigned first_lparen_token = ast->first_lparen_token;
|
||||
// unsigned second_lparen_token = ast->second_lparen_token;
|
||||
for (AttributeListAST *it = ast->attribute_list; it; it = it->next) {
|
||||
for (GnuAttributeListAST *it = ast->attribute_list; it; it = it->next) {
|
||||
this->attribute(it->value);
|
||||
}
|
||||
// unsigned first_rparen_token = ast->first_rparen_token;
|
||||
|
||||
7
src/libs/3rdparty/cplusplus/Bind.h
vendored
7
src/libs/3rdparty/cplusplus/Bind.h
vendored
@@ -77,7 +77,7 @@ protected:
|
||||
unsigned calculateScopeStart(ObjCProtocolDeclarationAST *ast) const;
|
||||
|
||||
const Name *objCSelectorArgument(ObjCSelectorArgumentAST *ast, bool *hasArg);
|
||||
void attribute(AttributeAST *ast);
|
||||
void attribute(GnuAttributeAST *ast);
|
||||
FullySpecifiedType declarator(DeclaratorAST *ast, const FullySpecifiedType &init, DeclaratorIdAST **declaratorId);
|
||||
void qtInterfaceName(QtInterfaceNameAST *ast);
|
||||
void baseSpecifier(BaseSpecifierAST *ast, unsigned colon_token, Class *klass);
|
||||
@@ -112,7 +112,7 @@ protected:
|
||||
|
||||
// AST
|
||||
virtual bool visit(ObjCSelectorArgumentAST *ast);
|
||||
virtual bool visit(AttributeAST *ast);
|
||||
virtual bool visit(GnuAttributeAST *ast);
|
||||
virtual bool visit(DeclaratorAST *ast);
|
||||
virtual bool visit(QtPropertyDeclarationItemAST *ast);
|
||||
virtual bool visit(QtInterfaceNameAST *ast);
|
||||
@@ -245,7 +245,8 @@ protected:
|
||||
|
||||
// SpecifierAST
|
||||
virtual bool visit(SimpleSpecifierAST *ast);
|
||||
virtual bool visit(AttributeSpecifierAST *ast);
|
||||
virtual bool visit(AlignmentSpecifierAST *ast);
|
||||
virtual bool visit(GnuAttributeSpecifierAST *ast);
|
||||
virtual bool visit(TypeofSpecifierAST *ast);
|
||||
virtual bool visit(DecltypeSpecifierAST *ast);
|
||||
virtual bool visit(ClassSpecifierAST *ast);
|
||||
|
||||
249
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
249
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
@@ -26,8 +26,13 @@
|
||||
#include "Literals.h"
|
||||
#include "ObjectiveCTypeQualifiers.h"
|
||||
#include "QtContextKeywords.h"
|
||||
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
#include <string>
|
||||
#include <cstdio> // for putchar
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1800)
|
||||
# define va_copy(dst, src) ((dst) = (src))
|
||||
#elif defined(__INTEL_COMPILER) && !defined(va_copy)
|
||||
@@ -43,9 +48,9 @@ using namespace CPlusPlus;
|
||||
namespace {
|
||||
|
||||
class DebugRule {
|
||||
public:
|
||||
static int depth;
|
||||
|
||||
public:
|
||||
DebugRule(const char *name, const char *spell, unsigned idx, bool blocked)
|
||||
{
|
||||
for (int i = 0; i <= depth; ++i)
|
||||
@@ -150,12 +155,93 @@ inline bool isRightAssociative(int tokenKind)
|
||||
|
||||
} // end of anonymous namespace
|
||||
|
||||
class Parser::ASTCache
|
||||
{
|
||||
ASTCache(const ASTCache &other);
|
||||
void operator =(const ASTCache &other);
|
||||
|
||||
public:
|
||||
enum ASTKind {
|
||||
Expression,
|
||||
ExpressionList,
|
||||
ParameterDeclarationClause,
|
||||
TypeId
|
||||
};
|
||||
|
||||
public:
|
||||
ASTCache() {}
|
||||
|
||||
void insert(ASTKind astKind, unsigned tokenIndexBeforeParsing,
|
||||
AST *resultingAST, unsigned resultingTokenIndex)
|
||||
{
|
||||
const auto key = std::make_pair(astKind, tokenIndexBeforeParsing);
|
||||
const auto value = std::make_pair(resultingAST, resultingTokenIndex);
|
||||
const auto keyValue = std::make_pair(key, value);
|
||||
_cache.insert(keyValue);
|
||||
}
|
||||
|
||||
AST *find(ASTKind astKind, unsigned tokenIndex,
|
||||
unsigned *resultingTokenIndex, bool *foundInCache) const
|
||||
{
|
||||
const auto key = std::make_pair(astKind, tokenIndex);
|
||||
const auto it = _cache.find(key);
|
||||
if (it == _cache.end()) {
|
||||
*foundInCache = false;
|
||||
return 0;
|
||||
} else {
|
||||
*foundInCache = true;
|
||||
*resultingTokenIndex = it->second.second;
|
||||
return it->second.first;
|
||||
}
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
_cache.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
struct KeyHasher {
|
||||
size_t operator()(const std::pair<int, unsigned> &key) const
|
||||
{ return std::hash<int>()(key.first) ^ std::hash<unsigned>()(key.second); }
|
||||
};
|
||||
|
||||
typedef std::pair<int, unsigned> ASTKindAndTokenIndex;
|
||||
typedef std::pair<AST *, unsigned> ASTAndTokenIndex;
|
||||
std::unordered_map<ASTKindAndTokenIndex, ASTAndTokenIndex, KeyHasher> _cache;
|
||||
};
|
||||
|
||||
#ifndef CPLUSPLUS_NO_DEBUG_RULE
|
||||
# define DEBUG_THIS_RULE() DebugRule __debug_rule__(__func__, tok().spell(), cursor(), _translationUnit->blockErrors())
|
||||
inline void debugPrintCheckCache(bool goodCase)
|
||||
{
|
||||
for (int i = 0; i <= DebugRule::depth - 1; ++i)
|
||||
fputc('-', stderr);
|
||||
if (goodCase)
|
||||
fprintf(stderr, " CACHE: Re-using AST from Cache.\n");
|
||||
else
|
||||
fprintf(stderr, " CACHE: Already tried to parse this, skipping.\n");
|
||||
}
|
||||
#else
|
||||
# define DEBUG_THIS_RULE() do {} while (0)
|
||||
inline void debugPrintCheckCache(bool) {}
|
||||
#endif
|
||||
|
||||
#define CHECK_CACHE(ASTKind, ASTType, returnValueInBadCase) \
|
||||
do { \
|
||||
bool foundInCache; \
|
||||
unsigned newTokenIndex; \
|
||||
if (AST *ast = _astCache->find(ASTKind, cursor(), &newTokenIndex, &foundInCache)) { \
|
||||
debugPrintCheckCache(true); \
|
||||
node = (ASTType *) ast; \
|
||||
_tokenIndex = newTokenIndex; \
|
||||
return true; \
|
||||
} else if (foundInCache) { \
|
||||
debugPrintCheckCache(false); \
|
||||
return returnValueInBadCase; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define PARSE_EXPRESSION_WITH_OPERATOR_PRECEDENCE(node, minPrecedence) { \
|
||||
if (LA() == T_THROW) { \
|
||||
if (!parseThrowExpression(node)) \
|
||||
@@ -175,14 +261,18 @@ Parser::Parser(TranslationUnit *unit)
|
||||
_tokenIndex(1),
|
||||
_templateArguments(0),
|
||||
_inFunctionBody(false),
|
||||
_inObjCImplementationContext(false),
|
||||
_inExpressionStatement(false),
|
||||
_expressionDepth(0),
|
||||
_statementDepth(0)
|
||||
_statementDepth(0),
|
||||
_astCache(new ASTCache),
|
||||
_expressionStatementAstCache(new ASTCache)
|
||||
{ }
|
||||
|
||||
Parser::~Parser()
|
||||
{ }
|
||||
{
|
||||
delete _expressionStatementAstCache;
|
||||
delete _astCache;
|
||||
}
|
||||
|
||||
bool Parser::switchTemplateArguments(bool templateArguments)
|
||||
{
|
||||
@@ -633,7 +723,7 @@ bool Parser::parseDeclaration(DeclarationAST *&node)
|
||||
if (_languageFeatures.objCEnabled && LA() == T___ATTRIBUTE__) {
|
||||
const unsigned start = cursor();
|
||||
SpecifierListAST *attributes = 0, **attr = &attributes;
|
||||
while (parseAttributeSpecifier(*attr))
|
||||
while (parseGnuAttributeSpecifier(*attr))
|
||||
attr = &(*attr)->next;
|
||||
if (LA() == T_AT_INTERFACE)
|
||||
return parseObjCInterface(node, attributes);
|
||||
@@ -761,11 +851,7 @@ bool Parser::parseNamespace(DeclarationAST *&node)
|
||||
ast->namespace_token = namespace_token;
|
||||
if (LA() == T_IDENTIFIER)
|
||||
ast->identifier_token = consumeToken();
|
||||
SpecifierListAST **attr_ptr = &ast->attribute_list;
|
||||
while (LA() == T___ATTRIBUTE__) {
|
||||
parseAttributeSpecifier(*attr_ptr);
|
||||
attr_ptr = &(*attr_ptr)->next;
|
||||
}
|
||||
parseOptionalAttributeSpecifierSequence(ast->attribute_list);
|
||||
if (LA() == T_LBRACE) {
|
||||
parseLinkageBody(ast->linkage_body);
|
||||
} else { // attempt to do error recovery
|
||||
@@ -1196,9 +1282,8 @@ bool Parser::parseCvQualifiers(SpecifierListAST *&node)
|
||||
spec->specifier_token = consumeToken();
|
||||
*ast = new (_pool) SpecifierListAST(spec);
|
||||
ast = &(*ast)->next;
|
||||
} else if (LA() == T___ATTRIBUTE__) {
|
||||
parseAttributeSpecifier(*ast);
|
||||
ast = &(*ast)->next;
|
||||
} else if (parseOptionalAttributeSpecifierSequence(*ast)) {
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@@ -1398,11 +1483,7 @@ bool Parser::parseCoreDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_sp
|
||||
DEBUG_THIS_RULE();
|
||||
unsigned start = cursor();
|
||||
SpecifierListAST *attributes = 0;
|
||||
SpecifierListAST **attribute_ptr = &attributes;
|
||||
while (LA() == T___ATTRIBUTE__) {
|
||||
parseAttributeSpecifier(*attribute_ptr);
|
||||
attribute_ptr = &(*attribute_ptr)->next;
|
||||
}
|
||||
parseOptionalAttributeSpecifierSequence(attributes);
|
||||
|
||||
PtrOperatorListAST *ptr_operators = 0, **ptr_operators_tail = &ptr_operators;
|
||||
while (parsePtrOperator(*ptr_operators_tail))
|
||||
@@ -1577,12 +1658,7 @@ bool Parser::parseDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_specif
|
||||
consumeToken(); // skip T_RPAREN
|
||||
}
|
||||
|
||||
SpecifierListAST **spec_ptr = &node->post_attribute_list;
|
||||
while (LA() == T___ATTRIBUTE__) {
|
||||
parseAttributeSpecifier(*spec_ptr);
|
||||
spec_ptr = &(*spec_ptr)->next;
|
||||
}
|
||||
|
||||
parseOptionalAttributeSpecifierSequence(node->post_attribute_list);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1856,6 +1932,8 @@ bool Parser::parseTypeParameter(DeclarationAST *&node)
|
||||
bool Parser::parseTypeId(ExpressionAST *&node)
|
||||
{
|
||||
DEBUG_THIS_RULE();
|
||||
CHECK_CACHE(ASTCache::TypeId, ExpressionAST, false);
|
||||
|
||||
SpecifierListAST *type_specifier = 0;
|
||||
if (parseTypeSpecifier(type_specifier)) {
|
||||
TypeIdAST *ast = new (_pool) TypeIdAST;
|
||||
@@ -1872,6 +1950,8 @@ bool Parser::parseParameterDeclarationClause(ParameterDeclarationClauseAST *&nod
|
||||
DEBUG_THIS_RULE();
|
||||
if (LA() == T_RPAREN)
|
||||
return true; // nothing to do
|
||||
CHECK_CACHE(ASTCache::ParameterDeclarationClause, ParameterDeclarationClauseAST, true);
|
||||
const unsigned initialCursor = cursor();
|
||||
|
||||
ParameterDeclarationListAST *parameter_declarations = 0;
|
||||
|
||||
@@ -1896,6 +1976,7 @@ bool Parser::parseParameterDeclarationClause(ParameterDeclarationClauseAST *&nod
|
||||
node = ast;
|
||||
}
|
||||
|
||||
_astCache->insert(ASTCache::ParameterDeclarationClause, initialCursor, node, cursor());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1985,11 +2066,8 @@ bool Parser::parseClassSpecifier(SpecifierListAST *&node)
|
||||
|
||||
unsigned classkey_token = consumeToken();
|
||||
|
||||
SpecifierListAST *attributes = 0, **attr_ptr = &attributes;
|
||||
while (LA() == T___ATTRIBUTE__) {
|
||||
parseAttributeSpecifier(*attr_ptr);
|
||||
attr_ptr = &(*attr_ptr)->next;
|
||||
}
|
||||
SpecifierListAST *attributes = 0;
|
||||
parseOptionalAttributeSpecifierSequence(attributes);
|
||||
|
||||
if (LA(1) == T_IDENTIFIER && LA(2) == T_IDENTIFIER) {
|
||||
const Identifier *id = tok(2).identifier;
|
||||
@@ -2464,12 +2542,8 @@ bool Parser::parseElaboratedTypeSpecifier(SpecifierListAST *&node)
|
||||
if (lookAtClassKey() || LA() == T_ENUM || LA() == T_TYPENAME) {
|
||||
unsigned classkey_token = consumeToken();
|
||||
|
||||
SpecifierListAST *attributes = 0, **attr_ptr = &attributes;
|
||||
while (LA() == T___ATTRIBUTE__) {
|
||||
parseAttributeSpecifier(*attr_ptr);
|
||||
attr_ptr = &(*attr_ptr)->next;
|
||||
}
|
||||
|
||||
SpecifierListAST *attributes = 0;
|
||||
parseOptionalAttributeSpecifierSequence(attributes);
|
||||
NameAST *name = 0;
|
||||
if (parseName(name)) {
|
||||
ElaboratedTypeSpecifierAST *ast = new (_pool) ElaboratedTypeSpecifierAST;
|
||||
@@ -2838,9 +2912,14 @@ bool Parser::parseTypeIdList(ExpressionListAST *&node)
|
||||
bool Parser::parseExpressionList(ExpressionListAST *&node)
|
||||
{
|
||||
DEBUG_THIS_RULE();
|
||||
CHECK_CACHE(ASTCache::ExpressionList, ExpressionListAST, false);
|
||||
unsigned initialCursor = cursor();
|
||||
|
||||
if (_languageFeatures.cxx11Enabled)
|
||||
return parseInitializerList0x(node);
|
||||
if (_languageFeatures.cxx11Enabled) {
|
||||
bool result = parseInitializerList0x(node);
|
||||
_astCache->insert(ASTCache::ExpressionList, initialCursor, (AST *) node, cursor());
|
||||
return result;
|
||||
}
|
||||
|
||||
ExpressionListAST **expression_list_ptr = &node;
|
||||
ExpressionAST *expression = 0;
|
||||
@@ -2857,9 +2936,11 @@ bool Parser::parseExpressionList(ExpressionListAST *&node)
|
||||
expression_list_ptr = &(*expression_list_ptr)->next;
|
||||
}
|
||||
}
|
||||
_astCache->insert(ASTCache::ExpressionList, initialCursor, (AST *) node, cursor());
|
||||
return true;
|
||||
}
|
||||
|
||||
_astCache->insert(ASTCache::ExpressionList, initialCursor, 0, cursor());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3022,9 +3103,11 @@ bool Parser::parseExpressionStatement(StatementAST *&node)
|
||||
const bool wasInExpressionStatement = _inExpressionStatement;
|
||||
_inExpressionStatement = true;
|
||||
|
||||
// switch to the temp pool
|
||||
// switch to the temp pool and cache
|
||||
MemoryPool *previousPool = _pool;
|
||||
_pool = &_expressionStatementTempPool;
|
||||
ASTCache *previousASTCache = _astCache;
|
||||
_astCache = _expressionStatementAstCache;
|
||||
|
||||
bool parsed = false;
|
||||
|
||||
@@ -3041,12 +3124,15 @@ bool Parser::parseExpressionStatement(StatementAST *&node)
|
||||
_inExpressionStatement = wasInExpressionStatement;
|
||||
|
||||
if (! _inExpressionStatement) {
|
||||
// rewind the memory pool after parsing a toplevel expression statement.
|
||||
// rewind the memory pool and cache after parsing a toplevel expression statement.
|
||||
_expressionStatementTempPool.reset();
|
||||
_astCache->clear();
|
||||
}
|
||||
|
||||
// restore the pool
|
||||
// restore the pool and cache
|
||||
_pool = previousPool;
|
||||
_astCache = previousASTCache;
|
||||
|
||||
return parsed;
|
||||
}
|
||||
|
||||
@@ -3799,39 +3885,83 @@ bool Parser::lookAtClassKey() const
|
||||
}
|
||||
}
|
||||
|
||||
bool Parser::parseAttributeSpecifier(SpecifierListAST *&node)
|
||||
bool Parser::parseOptionalAttributeSpecifierSequence(SpecifierListAST *&attribute_list)
|
||||
{
|
||||
bool didRead = false;
|
||||
while (parseAttributeSpecifier(attribute_list))
|
||||
didRead = true;
|
||||
return didRead;
|
||||
}
|
||||
|
||||
bool Parser::parseAttributeSpecifier(SpecifierListAST *&attribute_list)
|
||||
{
|
||||
SpecifierListAST **attr_ptr = &attribute_list;
|
||||
switch (LA()) {
|
||||
case T_ALIGNAS: {
|
||||
AlignmentSpecifierAST *ast = new (_pool) AlignmentSpecifierAST;
|
||||
ast->align_token = consumeToken();
|
||||
match(T_LPAREN, &ast->lparen_token);
|
||||
|
||||
const unsigned saved = cursor();
|
||||
if (!parseTypeId(ast->typeIdExprOrAlignmentExpr) ||
|
||||
(LA() != T_RPAREN &&
|
||||
(LA(1) != T_DOT_DOT_DOT || LA(2) != T_RPAREN))) {
|
||||
rewind(saved);
|
||||
parseExpression(ast->typeIdExprOrAlignmentExpr);
|
||||
}
|
||||
|
||||
if (LA() == T_DOT_DOT_DOT)
|
||||
ast->ellipses_token = consumeToken();
|
||||
match(T_RPAREN, &ast->rparen_token);
|
||||
attribute_list = new (_pool) SpecifierListAST(ast);
|
||||
return true;
|
||||
}
|
||||
//### TODO: C++11-style attributes
|
||||
// case T_LBRACKET:
|
||||
case T___ATTRIBUTE__:
|
||||
while (LA() == T___ATTRIBUTE__) {
|
||||
parseGnuAttributeSpecifier(*attr_ptr);
|
||||
attr_ptr = &(*attr_ptr)->next;
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Parser::parseGnuAttributeSpecifier(SpecifierListAST *&node)
|
||||
{
|
||||
DEBUG_THIS_RULE();
|
||||
if (LA() != T___ATTRIBUTE__)
|
||||
return false;
|
||||
|
||||
AttributeSpecifierAST *ast = new (_pool) AttributeSpecifierAST;
|
||||
GnuAttributeSpecifierAST *ast = new (_pool) GnuAttributeSpecifierAST;
|
||||
ast->attribute_token = consumeToken();
|
||||
match(T_LPAREN, &ast->first_lparen_token);
|
||||
match(T_LPAREN, &ast->second_lparen_token);
|
||||
parseAttributeList(ast->attribute_list);
|
||||
parseGnuAttributeList(ast->attribute_list);
|
||||
match(T_RPAREN, &ast->first_rparen_token);
|
||||
match(T_RPAREN, &ast->second_rparen_token);
|
||||
node = new (_pool) SpecifierListAST(ast);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Parser::parseAttributeList(AttributeListAST *&node)
|
||||
bool Parser::parseGnuAttributeList(GnuAttributeListAST *&node)
|
||||
{
|
||||
DEBUG_THIS_RULE();
|
||||
|
||||
AttributeListAST **iter = &node;
|
||||
GnuAttributeListAST **iter = &node;
|
||||
while (LA() == T_CONST || LA() == T_IDENTIFIER) {
|
||||
*iter = new (_pool) AttributeListAST;
|
||||
*iter = new (_pool) GnuAttributeListAST;
|
||||
|
||||
if (LA() == T_CONST) {
|
||||
AttributeAST *attr = new (_pool) AttributeAST;
|
||||
GnuAttributeAST *attr = new (_pool) GnuAttributeAST;
|
||||
attr->identifier_token = consumeToken();
|
||||
|
||||
(*iter)->value = attr;
|
||||
iter = &(*iter)->next;
|
||||
} else if (LA() == T_IDENTIFIER) {
|
||||
AttributeAST *attr = new (_pool) AttributeAST;
|
||||
GnuAttributeAST *attr = new (_pool) GnuAttributeAST;
|
||||
attr->identifier_token = consumeToken();
|
||||
if (LA() == T_LPAREN) {
|
||||
attr->lparen_token = consumeToken();
|
||||
@@ -3856,7 +3986,7 @@ bool Parser::parseBuiltinTypeSpecifier(SpecifierListAST *&node)
|
||||
{
|
||||
DEBUG_THIS_RULE();
|
||||
if (LA() == T___ATTRIBUTE__) {
|
||||
return parseAttributeSpecifier(node);
|
||||
return parseGnuAttributeSpecifier(node);
|
||||
} else if (LA() == T___TYPEOF__) {
|
||||
TypeofSpecifierAST *ast = new (_pool) TypeofSpecifierAST;
|
||||
ast->typeof_token = consumeToken();
|
||||
@@ -3912,8 +4042,7 @@ bool Parser::parseSimpleDeclaration(DeclarationAST *&node, ClassSpecifierAST *de
|
||||
spec->specifier_token = consumeToken();
|
||||
*decl_specifier_seq_ptr = new (_pool) SpecifierListAST(spec);
|
||||
decl_specifier_seq_ptr = &(*decl_specifier_seq_ptr)->next;
|
||||
} else if (LA() == T___ATTRIBUTE__) {
|
||||
parseAttributeSpecifier(*decl_specifier_seq_ptr);
|
||||
} else if (parseAttributeSpecifier(*decl_specifier_seq_ptr)) {
|
||||
decl_specifier_seq_ptr = &(*decl_specifier_seq_ptr)->next;
|
||||
} else if (! named_type_specifier && ! has_complex_type_specifier && lookAtBuiltinTypeSpecifier()) {
|
||||
parseBuiltinTypeSpecifier(*decl_specifier_seq_ptr);
|
||||
@@ -5244,6 +5373,7 @@ bool Parser::parseCastExpression(ExpressionAST *&node)
|
||||
DEBUG_THIS_RULE();
|
||||
if (LA() == T_LPAREN) {
|
||||
unsigned lparen_token = consumeToken();
|
||||
unsigned initialCursor = cursor();
|
||||
ExpressionAST *type_id = 0;
|
||||
if (parseTypeId(type_id) && LA() == T_RPAREN) {
|
||||
|
||||
@@ -5298,6 +5428,7 @@ bool Parser::parseCastExpression(ExpressionAST *&node)
|
||||
}
|
||||
|
||||
parse_as_unary_expression:
|
||||
_astCache->insert(ASTCache::TypeId, initialCursor, 0, cursor());
|
||||
rewind(lparen_token);
|
||||
}
|
||||
|
||||
@@ -5398,6 +5529,8 @@ bool Parser::parseConstantExpression(ExpressionAST *&node)
|
||||
bool Parser::parseExpression(ExpressionAST *&node)
|
||||
{
|
||||
DEBUG_THIS_RULE();
|
||||
CHECK_CACHE(ASTCache::Expression, ExpressionAST, false);
|
||||
unsigned initialCursor = cursor();
|
||||
|
||||
if (_expressionDepth > MAX_EXPRESSION_DEPTH)
|
||||
return false;
|
||||
@@ -5405,6 +5538,8 @@ bool Parser::parseExpression(ExpressionAST *&node)
|
||||
++_expressionDepth;
|
||||
bool success = parseCommaExpression(node);
|
||||
--_expressionDepth;
|
||||
|
||||
_astCache->insert(ASTCache::Expression, initialCursor, node, cursor());
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -5628,7 +5763,7 @@ bool Parser::parseObjCInterface(DeclarationAST *&node,
|
||||
DEBUG_THIS_RULE();
|
||||
if (! attributes && LA() == T___ATTRIBUTE__) {
|
||||
SpecifierListAST **attr = &attributes;
|
||||
while (parseAttributeSpecifier(*attr))
|
||||
while (parseGnuAttributeSpecifier(*attr))
|
||||
attr = &(*attr)->next;
|
||||
}
|
||||
|
||||
@@ -5717,7 +5852,7 @@ bool Parser::parseObjCProtocol(DeclarationAST *&node,
|
||||
DEBUG_THIS_RULE();
|
||||
if (! attributes && LA() == T___ATTRIBUTE__) {
|
||||
SpecifierListAST **attr = &attributes;
|
||||
while (parseAttributeSpecifier(*attr))
|
||||
while (parseGnuAttributeSpecifier(*attr))
|
||||
attr = &(*attr)->next;
|
||||
}
|
||||
|
||||
@@ -6219,7 +6354,7 @@ bool Parser::parseObjCMethodPrototype(ObjCMethodPrototypeAST *&node)
|
||||
}
|
||||
|
||||
SpecifierListAST **attr = &ast->attribute_list;
|
||||
while (parseAttributeSpecifier(*attr))
|
||||
while (parseGnuAttributeSpecifier(*attr))
|
||||
attr = &(*attr)->next;
|
||||
|
||||
node = ast;
|
||||
@@ -6328,7 +6463,7 @@ bool Parser::parseObjCKeywordDeclaration(ObjCSelectorArgumentAST *&argument, Obj
|
||||
parseObjCTypeName(node->type_name);
|
||||
|
||||
SpecifierListAST **attr = &node->attribute_list;
|
||||
while (parseAttributeSpecifier(*attr))
|
||||
while (parseGnuAttributeSpecifier(*attr))
|
||||
attr = &(*attr)->next;
|
||||
|
||||
SimpleNameAST *param_name = new (_pool) SimpleNameAST;
|
||||
@@ -6528,7 +6663,7 @@ bool Parser::parseLambdaDeclarator(LambdaDeclaratorAST *&node)
|
||||
match(T_RPAREN, &ast->rparen_token);
|
||||
|
||||
SpecifierListAST **attr = &ast->attributes;
|
||||
while (parseAttributeSpecifier(*attr))
|
||||
while (parseGnuAttributeSpecifier(*attr))
|
||||
attr = &(*attr)->next;
|
||||
|
||||
if (LA() == T_MUTABLE)
|
||||
@@ -6552,7 +6687,7 @@ bool Parser::parseTrailingReturnType(TrailingReturnTypeAST *&node)
|
||||
ast->arrow_token = consumeToken();
|
||||
|
||||
SpecifierListAST **attr = &ast->attributes;
|
||||
while (parseAttributeSpecifier(*attr))
|
||||
while (parseGnuAttributeSpecifier(*attr))
|
||||
attr = &(*attr)->next;
|
||||
|
||||
parseTrailingTypeSpecifierSeq(ast->type_specifier_list);
|
||||
|
||||
12
src/libs/3rdparty/cplusplus/Parser.h
vendored
12
src/libs/3rdparty/cplusplus/Parser.h
vendored
@@ -164,8 +164,10 @@ public:
|
||||
bool parseTypeParameter(DeclarationAST *&node);
|
||||
|
||||
bool parseBuiltinTypeSpecifier(SpecifierListAST *&node);
|
||||
bool parseAttributeSpecifier(SpecifierListAST *&node);
|
||||
bool parseAttributeList(AttributeListAST *&node);
|
||||
bool parseOptionalAttributeSpecifierSequence(SpecifierListAST *&attribute_list);
|
||||
bool parseAttributeSpecifier(SpecifierListAST *&attribute_list);
|
||||
bool parseGnuAttributeSpecifier(SpecifierListAST *&node);
|
||||
bool parseGnuAttributeList(GnuAttributeListAST *&node);
|
||||
|
||||
bool parseDeclSpecifierSeq(SpecifierListAST *&node,
|
||||
bool noStorageSpecifiers = false,
|
||||
@@ -316,7 +318,6 @@ private:
|
||||
unsigned _tokenIndex;
|
||||
bool _templateArguments: 1;
|
||||
bool _inFunctionBody: 1;
|
||||
bool _inObjCImplementationContext: 1;
|
||||
bool _inExpressionStatement: 1;
|
||||
int _expressionDepth;
|
||||
int _statementDepth;
|
||||
@@ -324,8 +325,9 @@ private:
|
||||
MemoryPool _expressionStatementTempPool;
|
||||
std::map<unsigned, TemplateArgumentListEntry> _templateArgumentList;
|
||||
|
||||
class Rewind;
|
||||
friend class Rewind;
|
||||
class ASTCache;
|
||||
ASTCache *_astCache;
|
||||
ASTCache *_expressionStatementAstCache;
|
||||
|
||||
private:
|
||||
Parser(const Parser& source);
|
||||
|
||||
Reference in New Issue
Block a user