C++: do not generate duplicated using statements for overloads in derived classes#1803
Merged
pwrobeldev merged 4 commits intomasterfrom Mar 3, 2026
Merged
Conversation
If method with the same name is declared in the base class and in the derived class, then to avoid warning (or error when -Werror is enabled) that is related to shadowing the methods from base class we need to add 'using' statement. However, it seems that C++ generator does not filter identical using statements when preparing the data for mustache template. The problem is reproduced by this commit to showcase wrong behavior in smoke tests. Signed-off-by: Patryk Wrobel <183546751+pwrobeldev@users.noreply.github.com>
This commit filters duplicated using statements for derived classes to avoid redundancy in the code. Signed-off-by: Patryk Wrobel <183546751+pwrobeldev@users.noreply.github.com>
The redundant using statements are removed by using filtering while generating the using statements in CPP generator. Signed-off-by: Patryk Wrobel <183546751+pwrobeldev@users.noreply.github.com>
Signed-off-by: Patryk Wrobel <183546751+pwrobeldev@users.noreply.github.com>
Contributor
Author
|
Additional reproducer to showcase why using is needed: |
Hsilgos
approved these changes
Mar 3, 2026
Contributor
Author
|
One additional note -- multiple using statements cause compilation failure: Therefore, this MR fixes the possible compilation failure. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
---------- Motivation ----------
When base and derived classes declare method with the same name,
then in the derived class we need to add 'using' statement to avoid
compiler warning/error related to shadowing.
It seems that when multiple function overloads were declared in the
derived class, then Gluecodium generated redundant using statements
which look like a bug.
---------- Solution ----------
Implemented filtering of prepared using statements to ensure that they
are unique (via
distinct()function call on list).This commit: