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
18931181
Commit
18931181
authored
Oct 04, 2010
by
Roberto Raggi
Browse files
Resolve local using namespace directives.
Reviewed-by: Erik Verbruggen
parent
5d2d3127
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/libs/cplusplus/LookupContext.cpp
View file @
18931181
...
...
@@ -238,8 +238,21 @@ ClassOrNamespace *LookupContext::globalNamespace() const
ClassOrNamespace
*
LookupContext
::
lookupType
(
const
Name
*
name
,
Scope
*
scope
)
const
{
if
(
ClassOrNamespace
*
b
=
bindings
()
->
lookupType
(
scope
))
if
(
!
scope
)
{
return
0
;
}
else
if
(
Block
*
block
=
scope
->
asBlock
())
{
for
(
unsigned
i
=
0
;
i
<
block
->
memberCount
();
++
i
)
{
if
(
UsingNamespaceDirective
*
u
=
block
->
memberAt
(
i
)
->
asUsingNamespaceDirective
())
{
if
(
ClassOrNamespace
*
uu
=
lookupType
(
u
->
name
(),
scope
->
enclosingNamespace
()))
{
if
(
ClassOrNamespace
*
r
=
uu
->
lookupType
(
name
))
return
r
;
}
}
}
return
lookupType
(
name
,
scope
->
enclosingScope
());
}
else
if
(
ClassOrNamespace
*
b
=
bindings
()
->
lookupType
(
scope
))
{
return
b
->
lookupType
(
name
);
}
return
0
;
}
...
...
@@ -257,25 +270,19 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
return
candidates
;
for
(;
scope
;
scope
=
scope
->
enclosingScope
())
{
if
(
(
name
->
i
sNameId
()
||
name
->
isTemplateNameId
())
&&
scope
->
isBlock
())
{
if
(
name
->
i
dentifier
()
!=
0
&&
scope
->
isBlock
())
{
bindings
()
->
lookupInScope
(
name
,
scope
,
&
candidates
,
/*templateId = */
0
,
/*binding=*/
0
);
if
(
!
candidates
.
isEmpty
())
break
;
// it's a local.
for
(
unsigned
index
=
0
;
index
<
scope
->
memberCount
();
++
index
)
{
Symbol
*
member
=
scope
->
memberAt
(
index
);
for
(
unsigned
i
=
0
;
i
<
scope
->
memberCount
();
++
i
)
{
if
(
UsingNamespaceDirective
*
u
=
scope
->
memberAt
(
i
)
->
asUsingNamespaceDirective
())
{
if
(
ClassOrNamespace
*
uu
=
lookupType
(
u
->
name
(),
scope
->
enclosingNamespace
()))
{
candidates
=
uu
->
find
(
name
);
if
(
UsingNamespaceDirective
*
u
=
member
->
asUsingNamespaceDirective
())
{
if
(
Namespace
*
enclosingNamespace
=
u
->
enclosingNamespace
()
->
asNamespace
())
{
if
(
ClassOrNamespace
*
b
=
bindings
()
->
lookupType
(
enclosingNamespace
))
{
if
(
ClassOrNamespace
*
uu
=
b
->
lookupType
(
u
->
name
()))
{
candidates
=
uu
->
find
(
name
);
if
(
!
candidates
.
isEmpty
())
return
candidates
;
}
}
if
(
!
candidates
.
isEmpty
())
return
candidates
;
}
}
}
...
...
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