Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Q
qt-creator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tobias Hunger
qt-creator
Commits
efb60066
Commit
efb60066
authored
Aug 12, 2010
by
Roberto Raggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remember the T_TEMPLATE token we use to force the parser to recognize a template-id.
parent
7f04af17
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
43 additions
and
27 deletions
+43
-27
src/plugins/cppeditor/cppchecksymbols.cpp
src/plugins/cppeditor/cppchecksymbols.cpp
+25
-21
src/shared/cplusplus/AST.cpp
src/shared/cplusplus/AST.cpp
+4
-0
src/shared/cplusplus/AST.h
src/shared/cplusplus/AST.h
+3
-1
src/shared/cplusplus/ASTClone.cpp
src/shared/cplusplus/ASTClone.cpp
+1
-0
src/shared/cplusplus/ASTMatcher.cpp
src/shared/cplusplus/ASTMatcher.cpp
+2
-0
src/shared/cplusplus/Parser.cpp
src/shared/cplusplus/Parser.cpp
+4
-3
src/shared/cplusplus/Parser.h
src/shared/cplusplus/Parser.h
+1
-1
tests/manual/cplusplus-dump/dumpers.inc
tests/manual/cplusplus-dump/dumpers.inc
+3
-1
No files found.
src/plugins/cppeditor/cppchecksymbols.cpp
View file @
efb60066
...
...
@@ -483,17 +483,8 @@ bool CheckSymbols::visit(NamedTypeSpecifierAST *)
bool
CheckSymbols
::
visit
(
ElaboratedTypeSpecifierAST
*
ast
)
{
accept
(
ast
->
attribute_list
);
if
(
ast
->
name
)
{
if
(
const
Name
*
name
=
ast
->
name
->
name
)
{
if
(
name
->
isNameId
()
||
name
->
isTemplateNameId
())
{
addUse
(
ast
->
name
,
Use
::
Type
);
return
false
;
}
}
}
accept
(
ast
->
name
);
addUse
(
ast
->
name
,
Use
::
Type
);
return
false
;
}
...
...
@@ -678,7 +669,7 @@ bool CheckSymbols::visit(DestructorNameAST *ast)
bool
CheckSymbols
::
visit
(
QualifiedNameAST
*
ast
)
{
if
(
ast
->
name
)
{
ClassOrNamespace
*
b
=
0
;
ClassOrNamespace
*
b
inding
=
0
;
if
(
NestedNameSpecifierListAST
*
it
=
ast
->
nested_name_specifier_list
)
{
NestedNameSpecifierAST
*
nested_name_specifier
=
it
->
value
;
if
(
NameAST
*
class_or_namespace_name
=
nested_name_specifier
->
class_or_namespace_name
)
{
// ### remove shadowing
...
...
@@ -687,29 +678,39 @@ bool CheckSymbols::visit(QualifiedNameAST *ast)
accept
(
template_id
->
template_argument_list
);
const
Name
*
name
=
class_or_namespace_name
->
name
;
b
=
_context
.
lookupType
(
name
,
enclosingScope
());
addType
(
b
,
class_or_namespace_name
);
b
inding
=
_context
.
lookupType
(
name
,
enclosingScope
());
addType
(
b
inding
,
class_or_namespace_name
);
for
(
it
=
it
->
next
;
b
&&
it
;
it
=
it
->
next
)
{
for
(
it
=
it
->
next
;
it
;
it
=
it
->
next
)
{
NestedNameSpecifierAST
*
nested_name_specifier
=
it
->
value
;
if
(
NameAST
*
class_or_namespace_name
=
nested_name_specifier
->
class_or_namespace_name
)
{
if
(
TemplateIdAST
*
template_id
=
class_or_namespace_name
->
asTemplateId
())
accept
(
template_id
->
template_argument_list
);
if
(
TemplateIdAST
*
template_id
=
class_or_namespace_name
->
asTemplateId
())
{
if
(
template_id
->
template_token
)
{
addUse
(
template_id
,
Use
::
Type
);
binding
=
0
;
// there's no way we can find a binding.
}
b
=
b
->
findType
(
class_or_namespace_name
->
name
);
addType
(
b
,
class_or_namespace_name
);
accept
(
template_id
->
template_argument_list
);
if
(
!
binding
)
continue
;
}
if
(
binding
)
{
binding
=
binding
->
findType
(
class_or_namespace_name
->
name
);
addType
(
binding
,
class_or_namespace_name
);
}
}
}
}
}
if
(
b
&&
ast
->
unqualified_name
)
{
if
(
b
inding
&&
ast
->
unqualified_name
)
{
if
(
ast
->
unqualified_name
->
asDestructorName
()
!=
0
)
{
if
(
hasVirtualDestructor
(
b
))
if
(
hasVirtualDestructor
(
b
inding
))
addUse
(
ast
->
unqualified_name
,
Use
::
VirtualMethod
);
}
else
{
addTypeOrStatic
(
b
->
find
(
ast
->
unqualified_name
->
name
),
ast
->
unqualified_name
);
addTypeOrStatic
(
b
inding
->
find
(
ast
->
unqualified_name
->
name
),
ast
->
unqualified_name
);
}
}
}
...
...
@@ -805,6 +806,9 @@ void CheckSymbols::addUse(NameAST *ast, Use::Kind kind)
if
(
DestructorNameAST
*
dtor
=
ast
->
asDestructorName
())
startToken
=
dtor
->
identifier_token
;
else
if
(
TemplateIdAST
*
templ
=
ast
->
asTemplateId
())
startToken
=
templ
->
identifier_token
;
addUse
(
startToken
,
kind
);
}
...
...
src/shared/cplusplus/AST.cpp
View file @
efb60066
...
...
@@ -3687,6 +3687,8 @@ unsigned TemplateDeclarationAST::lastToken() const
/** \generated */
unsigned
TemplateIdAST
::
firstToken
()
const
{
if
(
template_token
)
return
template_token
;
if
(
identifier_token
)
return
identifier_token
;
if
(
less_token
)
...
...
@@ -3711,6 +3713,8 @@ unsigned TemplateIdAST::lastToken() const
return
less_token
+
1
;
if
(
identifier_token
)
return
identifier_token
+
1
;
if
(
template_token
)
return
template_token
+
1
;
return
0
;
}
...
...
src/shared/cplusplus/AST.h
View file @
efb60066
...
...
@@ -2214,6 +2214,7 @@ protected:
class
CPLUSPLUS_EXPORT
TemplateIdAST
:
public
NameAST
{
public:
unsigned
template_token
;
unsigned
identifier_token
;
unsigned
less_token
;
ExpressionListAST
*
template_argument_list
;
...
...
@@ -2221,7 +2222,8 @@ public:
public:
TemplateIdAST
()
:
identifier_token
(
0
)
:
template_token
(
0
)
,
identifier_token
(
0
)
,
less_token
(
0
)
,
template_argument_list
(
0
)
,
greater_token
(
0
)
...
...
src/shared/cplusplus/ASTClone.cpp
View file @
efb60066
...
...
@@ -802,6 +802,7 @@ DestructorNameAST *DestructorNameAST::clone(MemoryPool *pool) const
TemplateIdAST
*
TemplateIdAST
::
clone
(
MemoryPool
*
pool
)
const
{
TemplateIdAST
*
ast
=
new
(
pool
)
TemplateIdAST
;
ast
->
template_token
=
template_token
;
ast
->
identifier_token
=
identifier_token
;
ast
->
less_token
=
less_token
;
for
(
ExpressionListAST
*
iter
=
template_argument_list
,
**
ast_iter
=
&
ast
->
template_argument_list
;
...
...
src/shared/cplusplus/ASTMatcher.cpp
View file @
efb60066
...
...
@@ -1347,6 +1347,8 @@ bool ASTMatcher::match(TemplateIdAST *node, TemplateIdAST *pattern)
(
void
)
node
;
(
void
)
pattern
;
pattern
->
template_token
=
node
->
template_token
;
pattern
->
identifier_token
=
node
->
identifier_token
;
pattern
->
less_token
=
node
->
less_token
;
...
...
src/shared/cplusplus/Parser.cpp
View file @
efb60066
...
...
@@ -419,14 +419,14 @@ bool Parser::parseClassOrNamespaceName(NameAST *&node)
}
}
else
if
(
LA
()
==
T_TEMPLATE
)
{
unsigned
template_token
=
consumeToken
();
if
(
parseTemplateId
(
node
))
if
(
parseTemplateId
(
node
,
template_token
))
return
true
;
rewind
(
template_token
);
}
return
false
;
}
bool
Parser
::
parseTemplateId
(
NameAST
*&
node
)
bool
Parser
::
parseTemplateId
(
NameAST
*&
node
,
unsigned
template_token
)
{
DEBUG_THIS_RULE
();
...
...
@@ -434,6 +434,7 @@ bool Parser::parseTemplateId(NameAST *&node)
if
(
LA
()
==
T_IDENTIFIER
&&
LA
(
2
)
==
T_LESS
)
{
TemplateIdAST
*
ast
=
new
(
_pool
)
TemplateIdAST
;
ast
->
template_token
=
template_token
;
ast
->
identifier_token
=
consumeToken
();
ast
->
less_token
=
consumeToken
();
if
(
LA
()
==
T_GREATER
||
parseTemplateArgumentList
(
...
...
@@ -2642,7 +2643,7 @@ bool Parser::parseUnqualifiedName(NameAST *&node, bool acceptTemplateId)
return
true
;
}
else
if
(
LA
()
==
T_TEMPLATE
)
{
unsigned
template_token
=
consumeToken
();
if
(
parseTemplateId
(
node
))
if
(
parseTemplateId
(
node
,
template_token
))
return
true
;
rewind
(
template_token
);
}
...
...
src/shared/cplusplus/Parser.h
View file @
efb60066
...
...
@@ -147,7 +147,7 @@ public:
bool
parseMemInitializerList
(
MemInitializerListAST
*&
node
);
bool
parseMemberSpecification
(
DeclarationAST
*&
node
);
bool
parseMultiplicativeExpression
(
ExpressionAST
*&
node
);
bool
parseTemplateId
(
NameAST
*&
node
);
bool
parseTemplateId
(
NameAST
*&
node
,
unsigned
template_token
=
0
);
bool
parseClassOrNamespaceName
(
NameAST
*&
node
);
bool
parseNameId
(
NameAST
*&
node
);
bool
parseName
(
NameAST
*&
node
,
bool
acceptTemplateId
=
true
);
...
...
tests/manual/cplusplus-dump/dumpers.inc
View file @
efb60066
...
...
@@ -771,11 +771,13 @@ virtual bool visit(DestructorNameAST *ast)
virtual
bool
visit
(
TemplateIdAST
*
ast
)
{
if
(
ast
->
template_token
)
terminal
(
ast
->
template_token
,
ast
);
if
(
ast
->
identifier_token
)
terminal
(
ast
->
identifier_token
,
ast
);
if
(
ast
->
less_token
)
terminal
(
ast
->
less_token
,
ast
);
for
(
TemplateArgument
ListAST
*
iter
=
ast
->
template_argument_list
;
iter
;
iter
=
iter
->
next
)
for
(
Expression
ListAST
*
iter
=
ast
->
template_argument_list
;
iter
;
iter
=
iter
->
next
)
nonterminal
(
iter
->
value
);
if
(
ast
->
greater_token
)
terminal
(
ast
->
greater_token
,
ast
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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