Skip to content

fix(util): handle known UFCS corner cases #506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Dec 3, 2023
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6e01f9a
fix(util): handle known UFCS corner cases
JohelEGP Aug 7, 2023
e423bab
refactor: regenerate `reflect.h`
JohelEGP Sep 14, 2023
50fd850
refactor(util): use new UFCS macros
JohelEGP Sep 14, 2023
c0e5cc3
test: add unit tests for fixed UFCS corner cases
JohelEGP Sep 14, 2023
0c4329c
test: regenerate regression tests
JohelEGP Sep 14, 2023
e60f076
refactor(util): remove old UFCS branch
JohelEGP Sep 14, 2023
f998496
refactor(util): comment the need for `CPP2_UFCS_IS_NOTHROW`
JohelEGP Nov 21, 2023
1fe5037
refactor(to_cpp1): split name lookup from `ufcs_possible`
JohelEGP Nov 21, 2023
38bc541
refactor(to_cpp1): clarify name of `ufcs_possible`
JohelEGP Nov 21, 2023
ecae575
refactor(to_cpp1): rename `stack` variables to `guard`
JohelEGP Nov 21, 2023
cb588c1
refactor(to_cpp1): add comment on added `stack` functions
JohelEGP Nov 21, 2023
1561fd3
refactor(to_cpp1): invert meaning of result to match rename
JohelEGP Nov 21, 2023
fc7e1fd
fix(to_cpp1): a using declaration doesn't name a variable
JohelEGP Nov 21, 2023
783d68d
fix(to_cpp1): do not capture in UFCS of type scope alias
JohelEGP Nov 23, 2023
b90cdfb
fix(to_cpp1): do not capture in UFCS of type scope alias
JohelEGP Nov 24, 2023
9643874
refactor(to_cpp1): regroup conditions more naturally
JohelEGP Nov 24, 2023
8ea0166
test: regenerate test-results
JohelEGP Nov 24, 2023
99a755a
fix(to_cpp1): do capture in UFCS of contract
JohelEGP Nov 24, 2023
295a886
test: regenerate test-results
JohelEGP Nov 24, 2023
0c8fa21
fix(to_cpp1): emit qualified UFCS template call correctly
JohelEGP Nov 24, 2023
55710ba
fix(to_cpp1): emit qualified UFCS template call correctly
JohelEGP Nov 24, 2023
811b5e8
fix(util): workaround MSVC bug for UFCS of 'F' in member 'F'
JohelEGP Nov 25, 2023
33cb7d5
test: disable the simpler test case due to the GCC bug
JohelEGP Nov 25, 2023
f7517ef
test: disable test cases now failing on MSVC
JohelEGP Nov 25, 2023
7f49d99
Results of testing the PR incl. with MSVC 2022
hsutter Nov 25, 2023
73d4b62
refactor(to_cpp1): apply review comment and rename name lookup
JohelEGP Nov 26, 2023
5302db0
test: regenerate test-results
JohelEGP Nov 26, 2023
d167f2b
test: add case for the happy path
JohelEGP Nov 30, 2023
8ad1335
test: regenerate UFCS tests
JohelEGP Dec 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(to_cpp1): invert meaning of result to match rename
  • Loading branch information
JohelEGP committed Dec 3, 2023
commit 1561fd35a2ec86b9bee71f7ed7191f9c478698f3
22 changes: 11 additions & 11 deletions source/to_cpp1.h
Original file line number Diff line number Diff line change
Expand Up @@ -2833,15 +2833,15 @@ class cppfront
{
if (!n.is_unqualified())
{
return true;
return false;
}

auto const& id = *get<id_expression_node::unqualified>(n.id);
auto lookup = unqualified_name_lookup(id);

if (!lookup)
{
return true;
return false;
}

if (
Expand All @@ -2856,26 +2856,26 @@ class cppfront
&& !(*decl)->is_object_alias()
)
{
return true;
return false;
}

if ((*decl)->is_object()) {
auto type = &**get_if<declaration_node::an_object>(&(*decl)->type);
return !type->is_wildcard()
|| !contains(current_declarations, *decl);
return type->is_wildcard()
&& contains(current_declarations, *decl);
}
auto const& type = (**get_if<declaration_node::an_alias>(&(*decl)->type)).type_id;
return (
type
&& !type->is_wildcard()
!type
|| type->is_wildcard()
)
|| !contains(current_declarations, *decl);
&& contains(current_declarations, *decl);
}
// else

auto using_ = get<cpp1_using_declaration>(*lookup);
return using_.identifier
&& *using_.identifier == *id.identifier;
return !using_.identifier
|| *using_.identifier != *id.identifier;
}

//-----------------------------------------------------------------------
Expand Down Expand Up @@ -3137,7 +3137,7 @@ class cppfront
// That happens when it finds that the function identifier being called
// is a variable with a placeholder type and we are in its initializer.
// So lower it to a member call instead, the only possible valid meaning.
&& lookup_finds_variable_with_placeholder_type_under_initialization(*i->id_expr)
&& !lookup_finds_variable_with_placeholder_type_under_initialization(*i->id_expr)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is another case, from #550 (comment).
It happens in a function expression, when lookup for the function name finds a variable outside the function expression that needs to be captured in order to be used.
UFCS should be disabled because, by definition, the function name can't be captured (#748).

)
{
auto funcname = print_to_string(*i->id_expr);
Expand Down