@@ -1836,7 +1836,7 @@ class cppfront
18361836
18371837 std::vector<token const *> looking_up = {};
18381838
1839- auto is_dependent_alias (token const & lookup_id)
1839+ auto is_dependent_type_alias (token const & lookup_id)
18401840 -> bool
18411841 {
18421842 // Prevent recursion.
@@ -1846,45 +1846,34 @@ class cppfront
18461846 looking_up.push_back (&lookup_id);
18471847 auto guard = finally ([&]{ looking_up.pop_back (); });
18481848
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+ }
18861874
1887- return res;
1875+ auto & type_id = get<alias_node::a_type>(alias->initializer );
1876+ return is_dependent (*type_id);
18881877 }
18891878
18901879 auto is_dependent (const type_id_node& n)
@@ -2041,7 +2030,7 @@ class cppfront
20412030 if (is_first && n.open_angle == source_position{}) {
20422031 assert (n.identifier );
20432032 return is_template_parameter (*n.identifier )
2044- || is_dependent_alias (*n.identifier );
2033+ || is_dependent_type_alias (*n.identifier );
20452034 }
20462035 // If it's a _template-id_
20472036 if (n.open_angle != source_position{}) {
@@ -3099,7 +3088,7 @@ class cppfront
30993088 }
31003089
31013090
3102- auto source_order_name_lookup (unqualified_id_node const & id )
3091+ auto source_order_name_lookup (std::string_view identifier )
31033092 -> source_order_name_lookup_res
31043093 {
31053094 for (
@@ -3112,7 +3101,7 @@ class cppfront
31123101 auto decl = get_if<declaration_node const *>(&*first);
31133102 decl
31143103 && *decl
3115- && (*decl)->has_name (*id. identifier )
3104+ && (*decl)->has_name (identifier)
31163105 )
31173106 {
31183107 return *decl;
@@ -3121,7 +3110,7 @@ class cppfront
31213110 auto using_ = get_if<active_using_declaration>(&*first);
31223111 using_
31233112 && using_->identifier
3124- && *using_->identifier == *id. identifier
3113+ && *using_->identifier == identifier
31253114 )
31263115 {
31273116 return *using_;
@@ -3141,7 +3130,7 @@ class cppfront
31413130 }
31423131
31433132 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 );
31453134
31463135 if (
31473136 !lookup
0 commit comments