Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
4fc2ccf0
Commit
4fc2ccf0
authored
Nov 10, 2009
by
Roberto Raggi
Browse files
Cleanup ptr operators.
parent
1fb33e9f
Changes
12
Hide whitespace changes
Inline
Side-by-side
src/libs/cplusplus/FindUsages.cpp
View file @
4fc2ccf0
...
...
@@ -409,8 +409,9 @@ bool FindUsages::visit(ParameterDeclarationAST *ast)
for
(
SpecifierAST
*
attr
=
declarator
->
attributes
;
attr
;
attr
=
attr
->
next
)
accept
(
attr
);
for
(
PtrOperatorAST
*
ptr_op
=
declarator
->
ptr_operators
;
ptr_op
;
ptr_op
=
ptr_op
->
next
)
accept
(
ptr_op
);
for
(
PtrOperatorListAST
*
it
=
declarator
->
ptr_operators
;
it
;
it
=
it
->
next
)
{
accept
(
it
->
value
);
}
if
(
!
_inSimpleDeclaration
)
// visit the core declarator only if we are not in simple-declaration.
accept
(
declarator
->
core_declarator
);
...
...
src/shared/cplusplus/AST.cpp
View file @
4fc2ccf0
...
...
@@ -483,10 +483,8 @@ unsigned ConversionFunctionIdAST::firstToken() const
unsigned
ConversionFunctionIdAST
::
lastToken
()
const
{
for
(
PtrOperatorAST
*
it
=
ptr_operators
;
it
;
it
=
it
->
next
)
{
if
(
!
it
->
next
)
return
it
->
lastToken
();
}
if
(
ptr_operators
)
return
ptr_operators
->
lastToken
();
for
(
SpecifierAST
*
it
=
type_specifier
;
it
;
it
=
it
->
next
)
{
if
(
!
it
->
next
)
...
...
@@ -566,10 +564,8 @@ unsigned DeclaratorAST::lastToken() const
if
(
core_declarator
)
return
core_declarator
->
lastToken
();
for
(
PtrOperatorAST
*
it
=
ptr_operators
;
it
;
it
=
it
->
next
)
{
if
(
!
it
->
next
)
return
it
->
lastToken
();
}
if
(
ptr_operators
)
return
ptr_operators
->
lastToken
();
for
(
SpecifierAST
*
it
=
attributes
;
it
;
it
=
it
->
next
)
{
if
(
!
it
->
next
)
...
...
@@ -1176,12 +1172,10 @@ unsigned NewTypeIdAST::lastToken() const
if
(
new_array_declarators
)
return
new_array_declarators
->
lastToken
();
for
(
PtrOperatorAST
*
it
=
ptr_operators
;
it
;
it
=
it
->
next
)
{
if
(
it
->
next
)
return
it
->
lastToken
();
}
else
if
(
ptr_operators
)
return
ptr_operators
->
lastToken
();
if
(
type_specifier
)
else
if
(
type_specifier
)
return
type_specifier
->
lastToken
();
// ### assert?
...
...
src/shared/cplusplus/AST.h
View file @
4fc2ccf0
...
...
@@ -371,7 +371,7 @@ class CPLUSPLUS_EXPORT DeclaratorAST: public AST
{
public:
SpecifierAST
*
attributes
;
PtrOperatorAST
*
ptr_operators
;
PtrOperator
List
AST
*
ptr_operators
;
CoreDeclaratorAST
*
core_declarator
;
PostfixDeclaratorListAST
*
postfix_declarators
;
SpecifierAST
*
post_attributes
;
...
...
@@ -1198,7 +1198,7 @@ class CPLUSPLUS_EXPORT ConversionFunctionIdAST: public NameAST
public:
unsigned
operator_token
;
SpecifierAST
*
type_specifier
;
PtrOperatorAST
*
ptr_operators
;
PtrOperator
List
AST
*
ptr_operators
;
public:
virtual
ConversionFunctionIdAST
*
asConversionFunctionId
()
{
return
this
;
}
...
...
@@ -1379,7 +1379,7 @@ class CPLUSPLUS_EXPORT NewTypeIdAST: public AST
{
public:
SpecifierAST
*
type_specifier
;
PtrOperatorAST
*
ptr_operators
;
PtrOperator
List
AST
*
ptr_operators
;
NewArrayDeclaratorListAST
*
new_array_declarators
;
public:
...
...
@@ -1591,12 +1591,8 @@ protected:
class
CPLUSPLUS_EXPORT
PtrOperatorAST
:
public
AST
{
public:
PtrOperatorAST
*
next
;
public:
virtual
PtrOperatorAST
*
asPtrOperator
()
{
return
this
;
}
};
class
CPLUSPLUS_EXPORT
PointerToMemberAST
:
public
PtrOperatorAST
...
...
src/shared/cplusplus/ASTVisit.cpp
View file @
4fc2ccf0
...
...
@@ -69,8 +69,7 @@ void DeclaratorAST::accept0(ASTVisitor *visitor)
if
(
visitor
->
visit
(
this
))
{
for
(
SpecifierAST
*
it
=
attributes
;
it
;
it
=
it
->
next
)
accept
(
it
,
visitor
);
for
(
PtrOperatorAST
*
it
=
ptr_operators
;
it
;
it
=
it
->
next
)
accept
(
it
,
visitor
);
accept
(
ptr_operators
,
visitor
);
accept
(
core_declarator
,
visitor
);
accept
(
postfix_declarators
,
visitor
);
for
(
SpecifierAST
*
it
=
post_attributes
;
it
;
it
=
it
->
next
)
...
...
@@ -472,8 +471,7 @@ void ConversionFunctionIdAST::accept0(ASTVisitor *visitor)
if
(
visitor
->
visit
(
this
))
{
for
(
SpecifierAST
*
it
=
type_specifier
;
it
;
it
=
it
->
next
)
accept
(
it
,
visitor
);
for
(
PtrOperatorAST
*
it
=
ptr_operators
;
it
;
it
=
it
->
next
)
accept
(
it
,
visitor
);
accept
(
ptr_operators
,
visitor
);
}
visitor
->
endVisit
(
this
);
}
...
...
@@ -560,8 +558,7 @@ void NewTypeIdAST::accept0(ASTVisitor *visitor)
if
(
visitor
->
visit
(
this
))
{
for
(
SpecifierAST
*
it
=
type_specifier
;
it
;
it
=
it
->
next
)
accept
(
it
,
visitor
);
for
(
PtrOperatorAST
*
it
=
ptr_operators
;
it
;
it
=
it
->
next
)
accept
(
it
,
visitor
);
accept
(
ptr_operators
,
visitor
);
accept
(
new_array_declarators
,
visitor
);
}
visitor
->
endVisit
(
this
);
...
...
src/shared/cplusplus/ASTfwd.h
View file @
4fc2ccf0
...
...
@@ -204,6 +204,7 @@ typedef List<PostfixDeclaratorAST *> PostfixDeclaratorListAST;
typedef
List
<
AttributeAST
*>
AttributeListAST
;
typedef
List
<
NestedNameSpecifierAST
*>
NestedNameSpecifierListAST
;
typedef
List
<
CatchClauseAST
*>
CatchClauseListAST
;
typedef
List
<
PtrOperatorAST
*>
PtrOperatorListAST
;
typedef
List
<
NameAST
*>
ObjCIdentifierListAST
;
typedef
List
<
ObjCMessageArgumentAST
*>
ObjCMessageArgumentListAST
;
...
...
src/shared/cplusplus/CheckDeclarator.cpp
View file @
4fc2ccf0
...
...
@@ -68,9 +68,9 @@ CheckDeclarator::~CheckDeclarator()
{
}
FullySpecifiedType
CheckDeclarator
::
check
(
DeclaratorAST
*
declarator
,
FullySpecifiedType
type
,
Scope
*
scope
,
Name
**
name
)
const
FullySpecifiedType
&
type
,
Scope
*
scope
,
Name
**
name
)
{
FullySpecifiedType
previousType
=
switchFullySpecifiedType
(
type
);
Scope
*
previousScope
=
switchScope
(
scope
);
...
...
@@ -83,9 +83,9 @@ FullySpecifiedType CheckDeclarator::check(DeclaratorAST *declarator,
return
switchFullySpecifiedType
(
previousType
);
}
FullySpecifiedType
CheckDeclarator
::
check
(
PtrOperatorAST
*
ptrOperators
,
FullySpecifiedType
type
,
Scope
*
scope
)
FullySpecifiedType
CheckDeclarator
::
check
(
PtrOperator
List
AST
*
ptrOperators
,
const
FullySpecifiedType
&
type
,
Scope
*
scope
)
{
FullySpecifiedType
previousType
=
switchFullySpecifiedType
(
type
);
Scope
*
previousScope
=
switchScope
(
scope
);
...
...
@@ -110,7 +110,7 @@ DeclaratorAST *CheckDeclarator::switchDeclarator(DeclaratorAST *declarator)
return
previousDeclarator
;
}
FullySpecifiedType
CheckDeclarator
::
switchFullySpecifiedType
(
FullySpecifiedType
type
)
FullySpecifiedType
CheckDeclarator
::
switchFullySpecifiedType
(
const
FullySpecifiedType
&
type
)
{
FullySpecifiedType
previousType
=
_fullySpecifiedType
;
_fullySpecifiedType
=
type
;
...
...
src/shared/cplusplus/CheckDeclarator.h
View file @
4fc2ccf0
...
...
@@ -63,20 +63,20 @@ public:
virtual
~
CheckDeclarator
();
FullySpecifiedType
check
(
DeclaratorAST
*
declarator
,
FullySpecifiedType
type
,
Scope
*
scope
,
Name
**
name
);
const
FullySpecifiedType
&
type
,
Scope
*
scope
,
Name
**
name
);
FullySpecifiedType
check
(
PtrOperatorAST
*
ptrOperators
,
FullySpecifiedType
type
,
Scope
*
scope
);
FullySpecifiedType
check
(
PtrOperator
List
AST
*
ptrOperators
,
const
FullySpecifiedType
&
type
,
Scope
*
scope
);
FullySpecifiedType
check
(
ObjCMethodPrototypeAST
*
methodPrototype
,
Scope
*
scope
);
protected:
DeclaratorAST
*
switchDeclarator
(
DeclaratorAST
*
declarator
);
FullySpecifiedType
switchFullySpecifiedType
(
FullySpecifiedType
type
);
FullySpecifiedType
switchFullySpecifiedType
(
const
FullySpecifiedType
&
type
);
Scope
*
switchScope
(
Scope
*
scope
);
Name
**
switchName
(
Name
**
name
);
...
...
src/shared/cplusplus/Parser.cpp
View file @
4fc2ccf0
...
...
@@ -661,7 +661,7 @@ bool Parser::parseConversionFunctionId(NameAST *&node)
if
(
!
parseTypeSpecifier
(
type_specifier
))
{
return
false
;
}
PtrOperatorAST
*
ptr_operators
=
0
,
**
ptr_operators_tail
=
&
ptr_operators
;
PtrOperator
List
AST
*
ptr_operators
=
0
,
**
ptr_operators_tail
=
&
ptr_operators
;
while
(
parsePtrOperator
(
*
ptr_operators_tail
))
ptr_operators_tail
=
&
(
*
ptr_operators_tail
)
->
next
;
...
...
@@ -956,19 +956,19 @@ bool Parser::parseCvQualifiers(SpecifierAST *&node)
return
start
!=
cursor
();
}
bool
Parser
::
parsePtrOperator
(
PtrOperatorAST
*&
node
)
bool
Parser
::
parsePtrOperator
(
PtrOperator
List
AST
*&
node
)
{
DEBUG_THIS_RULE
();
if
(
LA
()
==
T_AMPER
)
{
ReferenceAST
*
ast
=
new
(
_pool
)
ReferenceAST
;
ast
->
amp_token
=
consumeToken
();
node
=
ast
;
node
=
new
(
_pool
)
PtrOperatorListAST
(
ast
)
;
return
true
;
}
else
if
(
LA
()
==
T_STAR
)
{
PointerAST
*
ast
=
new
(
_pool
)
PointerAST
;
ast
->
star_token
=
consumeToken
();
parseCvQualifiers
(
ast
->
cv_qualifier_seq
);
node
=
ast
;
node
=
new
(
_pool
)
PtrOperatorListAST
(
ast
)
;
return
true
;
}
else
if
(
LA
()
==
T_COLON_COLON
||
LA
()
==
T_IDENTIFIER
)
{
unsigned
scope_or_identifier_token
=
cursor
();
...
...
@@ -985,7 +985,7 @@ bool Parser::parsePtrOperator(PtrOperatorAST *&node)
ast
->
nested_name_specifier
=
nested_name_specifiers
;
ast
->
star_token
=
consumeToken
();
parseCvQualifiers
(
ast
->
cv_qualifier_seq
);
node
=
ast
;
node
=
new
(
_pool
)
PtrOperatorListAST
(
ast
)
;
return
true
;
}
rewind
(
scope_or_identifier_token
);
...
...
@@ -1082,7 +1082,7 @@ bool Parser::parseCoreDeclarator(DeclaratorAST *&node)
attribute_ptr
=
&
(
*
attribute_ptr
)
->
next
;
}
PtrOperatorAST
*
ptr_operators
=
0
,
**
ptr_operators_tail
=
&
ptr_operators
;
PtrOperator
List
AST
*
ptr_operators
=
0
,
**
ptr_operators_tail
=
&
ptr_operators
;
while
(
parsePtrOperator
(
*
ptr_operators_tail
))
ptr_operators_tail
=
&
(
*
ptr_operators_tail
)
->
next
;
...
...
@@ -1219,7 +1219,8 @@ bool Parser::parseDeclarator(DeclaratorAST *&node, bool stopAtCppInitializer)
bool
Parser
::
parseAbstractCoreDeclarator
(
DeclaratorAST
*&
node
)
{
DEBUG_THIS_RULE
();
PtrOperatorAST
*
ptr_operators
=
0
,
**
ptr_operators_tail
=
&
ptr_operators
;
PtrOperatorListAST
*
ptr_operators
=
0
,
**
ptr_operators_tail
=
&
ptr_operators
;
while
(
parsePtrOperator
(
*
ptr_operators_tail
))
ptr_operators_tail
=
&
(
*
ptr_operators_tail
)
->
next
;
...
...
@@ -3799,12 +3800,15 @@ bool Parser::parseNewTypeId(NewTypeIdAST *&node)
NewTypeIdAST
*
ast
=
new
(
_pool
)
NewTypeIdAST
;
ast
->
type_specifier
=
typeSpec
;
PtrOperatorAST
**
ptrop_it
=
&
ast
->
ptr_operators
;
PtrOperatorListAST
**
ptrop_it
=
&
ast
->
ptr_operators
;
while
(
parsePtrOperator
(
*
ptrop_it
))
ptrop_it
=
&
(
*
ptrop_it
)
->
next
;
NewArrayDeclaratorListAST
**
it
=
&
ast
->
new_array_declarators
;
while
(
parseNewArrayDeclarator
(
*
it
))
it
=
&
(
*
it
)
->
next
;
node
=
ast
;
return
true
;
}
...
...
src/shared/cplusplus/Parser.h
View file @
4fc2ccf0
...
...
@@ -165,7 +165,7 @@ public:
bool
parsePostfixExpressionInternal
(
ExpressionAST
*&
node
);
bool
parsePrimaryExpression
(
ExpressionAST
*&
node
);
bool
parseNestedExpression
(
ExpressionAST
*&
node
);
bool
parsePtrOperator
(
PtrOperatorAST
*&
node
);
bool
parsePtrOperator
(
PtrOperator
List
AST
*&
node
);
bool
parseRelationalExpression
(
ExpressionAST
*&
node
);
bool
parseShiftExpression
(
ExpressionAST
*&
node
);
bool
parseStatement
(
StatementAST
*&
node
);
...
...
src/shared/cplusplus/Semantic.cpp
View file @
4fc2ccf0
...
...
@@ -130,7 +130,7 @@ FullySpecifiedType Semantic::check(DeclaratorAST *declarator, FullySpecifiedType
Scope
*
scope
,
Name
**
name
)
{
return
d
->
checkDeclarator
->
check
(
declarator
,
type
,
scope
,
name
);
}
FullySpecifiedType
Semantic
::
check
(
PtrOperatorAST
*
ptrOperators
,
FullySpecifiedType
type
,
FullySpecifiedType
Semantic
::
check
(
PtrOperator
List
AST
*
ptrOperators
,
FullySpecifiedType
type
,
Scope
*
scope
)
{
return
d
->
checkDeclarator
->
check
(
ptrOperators
,
type
,
scope
);
}
...
...
src/shared/cplusplus/Semantic.h
View file @
4fc2ccf0
...
...
@@ -71,7 +71,7 @@ public:
FullySpecifiedType
check
(
DeclaratorAST
*
declarator
,
FullySpecifiedType
type
,
Scope
*
scope
,
Name
**
name
=
0
);
// ### ugly
FullySpecifiedType
check
(
PtrOperatorAST
*
ptrOperators
,
FullySpecifiedType
type
,
FullySpecifiedType
check
(
PtrOperator
List
AST
*
ptrOperators
,
FullySpecifiedType
type
,
Scope
*
scope
);
FullySpecifiedType
check
(
ObjCMethodPrototypeAST
*
methodPrototype
,
Scope
*
scope
);
...
...
tests/auto/cplusplus/ast/tst_ast.cpp
View file @
4fc2ccf0
...
...
@@ -668,7 +668,9 @@ void tst_AST::objc_msg_send_expression()
QVERIFY
(
declarator
);
QVERIFY
(
!
declarator
->
attributes
);
QVERIFY
(
declarator
->
ptr_operators
&&
!
declarator
->
ptr_operators
->
next
&&
declarator
->
ptr_operators
->
asPointer
()
&&
!
declarator
->
ptr_operators
->
asPointer
()
->
cv_qualifier_seq
);
QVERIFY
(
declarator
->
ptr_operators
&&
!
declarator
->
ptr_operators
->
next
&&
declarator
->
ptr_operators
->
value
->
asPointer
()
&&
!
declarator
->
ptr_operators
->
value
->
asPointer
()
->
cv_qualifier_seq
);
QVERIFY
(
declarator
->
core_declarator
&&
declarator
->
core_declarator
->
asDeclaratorId
());
NameAST
*
objNameId
=
declarator
->
core_declarator
->
asDeclaratorId
()
->
name
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment