Skip to content
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

Add GetEnumConstantDatamembers function #499

Merged

Conversation

Vipul-Cariappa
Copy link
Collaborator

Resolve all EnumConstantDecls declared in a class.

Fixes # (issue)

1 test at cppyy.

Please tick all options which are relevant.

  • Bug fix
  • New feature
  • Requires documentation updates

Testing

Implemented tests.

Checklist

  • I have read the contribution guide recently

Copy link

codecov bot commented Feb 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.26%. Comparing base (b797dbb) to head (97c8602).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #499      +/-   ##
==========================================
+ Coverage   71.17%   71.26%   +0.09%     
==========================================
  Files           9        9              
  Lines        3552     3564      +12     
==========================================
+ Hits         2528     2540      +12     
  Misses       1024     1024              
Files with missing lines Coverage Δ
include/clang/Interpreter/CppInterOp.h 96.29% <ø> (ø)
lib/Interpreter/CppInterOp.cpp 80.57% <100.00%> (+0.12%) ⬆️
Files with missing lines Coverage Δ
include/clang/Interpreter/CppInterOp.h 96.29% <ø> (ø)
lib/Interpreter/CppInterOp.cpp 80.57% <100.00%> (+0.12%) ⬆️

Copy link
Contributor

github-actions bot commented Feb 9, 2025

clang-tidy review says "All clean, LGTM! 👍"

Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

auto* ED = static_cast<EnumDecl*>(i);

bool is_class_tagged = ED->isScopedUsingClassTag();
if ((is_class_tagged) && !(is_class_tagged && include_class_enum))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if ((is_class_tagged) && !(is_class_tagged && include_class_enum))
if (is_class_tagged || !include_class_enum)

Isn't that what you mean? Only include scoped enums when the user requested?

Comment on lines 1238 to 1240
for (auto iterator = ED->enumerator_begin();
iterator != ED->enumerator_end(); iterator++)
datamembers.push_back(*iterator);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for (auto iterator = ED->enumerator_begin();
iterator != ED->enumerator_end(); iterator++)
datamembers.push_back(*iterator);
std::copy(ED->enumerator_begin(), ED->enumerator_end(), std::back_inserter(dm));

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

if (is_class_tagged && !include_enum_class)
continue;

std::copy(ED->enumerator_begin(), ED->enumerator_end(),
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "std::copy" is directly included [misc-include-cleaner]

lib/Interpreter/CppInterOp.cpp:26:

- #if CLANG_VERSION_MAJOR >= 19
+ #include <algorithm>
+ #if CLANG_VERSION_MAJOR >= 19

continue;

std::copy(ED->enumerator_begin(), ED->enumerator_end(),
std::back_inserter(datamembers));
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "std::back_inserter" is directly included [misc-include-cleaner]

lib/Interpreter/CppInterOp.cpp:26:

- #if CLANG_VERSION_MAJOR >= 19
+ #include <iterator>
+ #if CLANG_VERSION_MAJOR >= 19

Copy link
Contributor

Choose a reason for hiding this comment

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

These are good suggestions...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

resolved.

to resolve all `EnumConstantDecl`s declared in a class
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copy link
Contributor

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

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

Lgtm!

@Vipul-Cariappa Vipul-Cariappa merged commit fc852d5 into compiler-research:main Feb 16, 2025
73 checks passed
@Vipul-Cariappa Vipul-Cariappa deleted the dev/EnumConstant branch February 16, 2025 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants