Skip to content

using getFirstDecl for TranslationUnitDecl for consistent pointers #329

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 1 commit into from
Sep 27, 2024

Conversation

Vipul-Cariappa
Copy link
Collaborator

Eight previously failing tests pass without any new failing tests in cppyy.
image

But EnumReflectionTest.GetEnums fails from the CppInterOp tests.
It looks like GetEnums cannot resolve any enums in the global scope.

@Vipul-Cariappa
Copy link
Collaborator Author

ping @vgvassilev @aaronj0
Any ideas on what is causing the CppInterOp failure?

Copy link
Contributor

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

@vgvassilev
Copy link
Contributor

Looks like some test is failing.

@vgvassilev
Copy link
Contributor

Eight previously failing tests pass without any new failing tests in cppyy. image

But EnumReflectionTest.GetEnums fails from the CppInterOp tests. It looks like GetEnums cannot resolve any enums in the global scope.

The problem is that the implementation is insufficient. To fix it, we need to iterate the redeclaration chains of NamespaceDecl and TranslationUnitDecl. That is, we should check if the Decl is Redeclarable and then do getMostRecentDecl() and loop until there is getPreviousDecl()...

@vgvassilev
Copy link
Contributor

Eight previously failing tests pass without any new failing tests in cppyy. image
But EnumReflectionTest.GetEnums fails from the CppInterOp tests. It looks like GetEnums cannot resolve any enums in the global scope.

The problem is that the implementation is insufficient. To fix it, we need to iterate the redeclaration chains of NamespaceDecl and TranslationUnitDecl. That is, we should check if the Decl is Redeclarable and then do getMostRecentDecl() and loop until there is getPreviousDecl()...

Even better DeclContext::collectAllContexts does it for us.

@Vipul-Cariappa
Copy link
Collaborator Author

The problem is that the implementation is insufficient. To fix it, we need to iterate the redeclaration chains of NamespaceDecl and TranslationUnitDecl.

Fixed. 👍🏽


Maybe there are other places where we will need to use DeclContext::collectAllContexts to resolve symbols.

Copy link
Contributor

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

@vgvassilev
Copy link
Contributor

The problem is that the implementation is insufficient. To fix it, we need to iterate the redeclaration chains of NamespaceDecl and TranslationUnitDecl.

Fixed. 👍🏽

Maybe there are other places where we will need to use DeclContext::collectAllContexts to resolve symbols.

Hopefully not, because this iteration generally is wrong. This need to be lookup-based approach instead of a brute forcing all namespaces and translation units... Please add a giant FIXME describing that.

Copy link

codecov bot commented Sep 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.71%. Comparing base (57d09bd) to head (2d2b70c).
Report is 3 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #329      +/-   ##
==========================================
+ Coverage   73.69%   73.71%   +0.02%     
==========================================
  Files           8        8              
  Lines        3018     3021       +3     
==========================================
+ Hits         2224     2227       +3     
  Misses        794      794              
Files with missing lines Coverage Δ
lib/Interpreter/CppInterOp.cpp 79.57% <100.00%> (+0.03%) ⬆️
Files with missing lines Coverage Δ
lib/Interpreter/CppInterOp.cpp 79.57% <100.00%> (+0.03%) ⬆️

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

Copy link
Contributor

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

1 similar comment
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!

@aaronj0
Copy link
Collaborator

aaronj0 commented Sep 27, 2024

@Vipul-Cariappa Can you rebase into a single commit?

Copy link
Contributor

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

@vgvassilev
Copy link
Contributor

The commit does more than it says?

refactored `GetEnums` for this change by using `collectAllContexts`
@Vipul-Cariappa
Copy link
Collaborator Author

The commit does more than it says?

The main purpose of the PR is to use getFirstDecl for TranslationUnitDecl. That breaks GetEnums therefore we had to refactor it to use collectAllContexts.

Hope the new commit message conveys the same.

Copy link
Contributor

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

@vgvassilev vgvassilev merged commit 0f406da into compiler-research:main Sep 27, 2024
59 checks passed
@Vipul-Cariappa Vipul-Cariappa deleted the decl branch September 27, 2024 11:38
Vipul-Cariappa added a commit to Vipul-Cariappa/cppyy-compiler-research that referenced this pull request Sep 28, 2024
Vipul-Cariappa added a commit to Vipul-Cariappa/cppyy-compiler-research that referenced this pull request Sep 28, 2024
vgvassilev pushed a commit to compiler-research/cppyy that referenced this pull request Sep 28, 2024
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.

3 participants