@@ -1836,7 +1836,7 @@ class cppfront
1836
1836
1837
1837
std::vector<token const *> looking_up = {};
1838
1838
1839
- auto is_dependent_alias (token const & lookup_id)
1839
+ auto is_dependent_type_alias (token const & lookup_id)
1840
1840
-> bool
1841
1841
{
1842
1842
// Prevent recursion.
@@ -1846,45 +1846,34 @@ class cppfront
1846
1846
looking_up.push_back (&lookup_id);
1847
1847
auto guard = finally ([&]{ looking_up.pop_back (); });
1848
1848
1849
- bool res = false ;
1850
- // If the first parent declaration
1851
- (void )std::find_if (
1852
- current_declarations.rbegin (),
1853
- current_declarations.rend () - 1 ,
1854
- [&](declaration_node const * decl)
1855
- {
1856
- // that can have aliases
1857
- if ((decl->is_function ()
1858
- || decl->is_type ()
1859
- || decl->is_namespace ())
1860
- && decl->initializer
1861
- && decl->initializer ->is_compound ())
1862
- {
1863
- auto & stmts = decl->initializer ->get_if <compound_statement_node>()->statements ;
1864
- // among its statements
1865
- return std::any_of (stmts.rbegin (), stmts.rend (), [&](decltype (stmts.front ())& stmt) {
1866
- if (auto decl = stmt->get_if <declaration_node>();
1867
- decl
1868
- && decl->is_alias ()) {
1869
- auto & alias = get<declaration_node::an_alias>(decl->type );
1870
- // has a type alias declaration of equal name
1871
- if (alias->is_type_alias ()
1872
- && decl->identifier
1873
- && *decl->identifier ->identifier == lookup_id) {
1874
- auto & type_id = get<alias_node::a_type>(alias->initializer );
1875
- // and its value is a dependent _type-id_.
1876
- res = is_dependent (*type_id);
1877
- return true ;
1878
- }
1879
- }
1880
- return false ;
1881
- });
1882
- }
1883
- return false ;
1884
- }
1885
- );
1849
+ auto lookup = source_order_name_lookup (lookup_id);
1850
+
1851
+ if (
1852
+ !lookup
1853
+ || get_if<active_using_declaration>(&*lookup)
1854
+ )
1855
+ {
1856
+ return false ;
1857
+ }
1858
+
1859
+ auto decl = get<declaration_node const *>(*lookup);
1860
+ if (!decl->is_alias ()) {
1861
+ return false ;
1862
+ }
1863
+
1864
+ auto & alias = get<declaration_node::an_alias>(decl->type );
1865
+
1866
+ if (
1867
+ !alias->is_type_alias ()
1868
+ || !decl->identifier
1869
+ || *decl->identifier ->identifier != lookup_id
1870
+ )
1871
+ {
1872
+ return false ;
1873
+ }
1886
1874
1887
- return res;
1875
+ auto & type_id = get<alias_node::a_type>(alias->initializer );
1876
+ return is_dependent (*type_id);
1888
1877
}
1889
1878
1890
1879
auto is_dependent (const type_id_node& n)
@@ -2041,7 +2030,7 @@ class cppfront
2041
2030
if (is_first && n.open_angle == source_position{}) {
2042
2031
assert (n.identifier );
2043
2032
return is_template_parameter (*n.identifier )
2044
- || is_dependent_alias (*n.identifier );
2033
+ || is_dependent_type_alias (*n.identifier );
2045
2034
}
2046
2035
// If it's a _template-id_
2047
2036
if (n.open_angle != source_position{}) {
@@ -3099,7 +3088,7 @@ class cppfront
3099
3088
}
3100
3089
3101
3090
3102
- auto source_order_name_lookup (unqualified_id_node const & id )
3091
+ auto source_order_name_lookup (std::string_view identifier )
3103
3092
-> source_order_name_lookup_res
3104
3093
{
3105
3094
for (
@@ -3112,7 +3101,7 @@ class cppfront
3112
3101
auto decl = get_if<declaration_node const *>(&*first);
3113
3102
decl
3114
3103
&& *decl
3115
- && (*decl)->has_name (*id. identifier )
3104
+ && (*decl)->has_name (identifier)
3116
3105
)
3117
3106
{
3118
3107
return *decl;
@@ -3121,7 +3110,7 @@ class cppfront
3121
3110
auto using_ = get_if<active_using_declaration>(&*first);
3122
3111
using_
3123
3112
&& using_->identifier
3124
- && *using_->identifier == *id. identifier
3113
+ && *using_->identifier == identifier
3125
3114
)
3126
3115
{
3127
3116
return *using_;
@@ -3141,7 +3130,7 @@ class cppfront
3141
3130
}
3142
3131
3143
3132
auto const & id = *get<id_expression_node::unqualified>(n.id );
3144
- auto lookup = source_order_name_lookup (id );
3133
+ auto lookup = source_order_name_lookup (*id. identifier );
3145
3134
3146
3135
if (
3147
3136
!lookup
0 commit comments