-
Couldn't load subscription status.
- Fork 35
Fix: resolve nested attributes of anonymous records in GetDatamembers #321
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
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a801568
Fix: resolve nested attributes of anonymous records in GetDatamembers
Vipul-Cariappa 846796b
Apply suggestions from code review (github-actions bot)
Vipul-Cariappa a2fd87e
suggestions from code review & disable anonymous struct warning for test
Vipul-Cariappa e837ec6
disabling warning if not windows
Vipul-Cariappa 34f0c4c
Apply suggestions from code review
Vipul-Cariappa e8dd9a1
suggestions from code review & skip test on valgrind
Vipul-Cariappa 25cf88d
Apply suggestions from code review
Vipul-Cariappa 36f9aee
clang format change
Vipul-Cariappa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1128,9 +1128,32 @@ namespace Cpp { | |||||
|
|
||||||
| if (auto *CXXRD = llvm::dyn_cast_or_null<CXXRecordDecl>(D)) { | ||||||
| std::vector<TCppScope_t> datamembers; | ||||||
| for (auto it = CXXRD->field_begin(), end = CXXRD->field_end(); it != end; | ||||||
| it++) { | ||||||
| datamembers.push_back((TCppScope_t)*it); | ||||||
| llvm::SmallVector<RecordDecl::field_iterator, 2> stack_begin; | ||||||
| llvm::SmallVector<RecordDecl::field_iterator, 2> stack_end; | ||||||
| stack_begin.push_back(CXXRD->field_begin()); | ||||||
| stack_end.push_back(CXXRD->field_end()); | ||||||
| while (!stack_begin.empty()) { | ||||||
| if (stack_begin.back() == stack_end.back()) { | ||||||
| stack_begin.pop_back(); | ||||||
| stack_end.pop_back(); | ||||||
| continue; | ||||||
| } | ||||||
| Decl* D = *(stack_begin.back()); | ||||||
| if (D->getKind() == clang::Decl::Field) { | ||||||
| if (auto* FD = llvm::dyn_cast<FieldDecl>(D)) { | ||||||
| if (FD->isAnonymousStructOrUnion()) { | ||||||
| if (auto* CXXRD = llvm::dyn_cast_or_null<CXXRecordDecl>( | ||||||
| FD->getType()->getAs<RecordType>()->getDecl())) { | ||||||
Vipul-Cariappa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| stack_begin.back()++; | ||||||
| stack_begin.push_back(CXXRD->field_begin()); | ||||||
| stack_end.push_back(CXXRD->field_end()); | ||||||
| continue; | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| datamembers.push_back((TCppScope_t)D); | ||||||
| stack_begin.back()++; | ||||||
| } | ||||||
|
|
||||||
| return datamembers; | ||||||
|
|
@@ -1175,9 +1198,30 @@ namespace Cpp { | |||||
| auto *D = (Decl *) var; | ||||||
| auto &C = getASTContext(); | ||||||
|
|
||||||
| if (auto *FD = llvm::dyn_cast<FieldDecl>(D)) | ||||||
| return (intptr_t) C.toCharUnitsFromBits(C.getASTRecordLayout(FD->getParent()) | ||||||
| .getFieldOffset(FD->getFieldIndex())).getQuantity(); | ||||||
| if (auto* FD = llvm::dyn_cast<FieldDecl>(D)) { | ||||||
| const clang::RecordDecl* RD = FD->getParent(); | ||||||
| intptr_t offset = | ||||||
| C.toCharUnitsFromBits( | ||||||
| C.getASTRecordLayout(RD).getFieldOffset(FD->getFieldIndex())) | ||||||
Vipul-Cariappa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| C.getASTRecordLayout(RD).getFieldOffset(FD->getFieldIndex())) | |
| C.getFieldOffset(FD) |
Vipul-Cariappa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Vipul-Cariappa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.