-
Notifications
You must be signed in to change notification settings - Fork 43
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
Refine types based on debug metadata #191
Draft
frabert
wants to merge
33
commits into
master
Choose a base branch
from
use-debug-types
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 3 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
9798e97
Initial work on refining types
frabert 49e2601
Visit global variables, improve return types
frabert b32d10a
Implement typedef printing
frabert 55d3a13
Improve type refinement for fields and arguments
frabert 2b1e41d
Fix struct members
frabert 7db935e
Add explanation for checking argument count
frabert 1067041
Add unit test for `ASTBuilder::CreateTypedefDecl`
frabert 0486438
Fix varargs debug type analysis
frabert 171e90e
Use more debug info for prototypes
frabert 09f8a2e
Fix function argument type refinement
frabert bdd21e4
Default to signed integers
frabert 7c474eb
Fix tests
frabert e0e6efe
Desugar types for Z3 conversion
frabert 175c073
Initial work on refining types
frabert b55a8d0
Visit global variables, improve return types
frabert 287e137
Implement typedef printing
frabert 2292193
Improve type refinement for fields and arguments
frabert c3da195
Fix struct members
frabert 36cb7c8
Add explanation for checking argument count
frabert 33294d3
Add unit test for `ASTBuilder::CreateTypedefDecl`
frabert e878d42
Fix varargs debug type analysis
frabert 6b4d302
Use more debug info for prototypes
frabert b231b24
Fix function argument type refinement
frabert e02bd8a
Default to signed integers
frabert 3676aa5
Fix tests
frabert a9b5371
Desugar types for Z3 conversion
frabert 0386c2b
Merge branch 'use-debug-types' of github.com:lifting-bits/rellic into…
frabert af69ad5
Merge branch 'master' into use-debug-types
frabert 8f39d9d
Add utility functions
frabert 35599ba
Fix bugs
frabert 2905038
Merge branch 'master' into use-debug-types
frabert dbd0d82
Add void to ptr casts
frabert 38991a6
Use plain `char` when asking for `signed char`
frabert 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 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 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 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 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 |
---|---|---|
|
@@ -60,6 +60,9 @@ bool StructFieldRenamer::VisitRecordDecl(clang::RecordDecl *decl) { | |
// FIXME(frabert): Is a clash between field names actually possible? | ||
// Can this mechanism actually be left out? | ||
auto name{di_field->getName().str()}; | ||
if (di_field->getTag() == llvm::dwarf::DW_TAG_inheritance) { | ||
name = di_field->getBaseType()->getName().str() + "_base"; | ||
} | ||
if (seen_names.find(name) == seen_names.end()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if you have auto &name_count = seen_names[name];
if (name_count) {
name = name + "_" + std::to_string(name_count);
}
++name_count; |
||
seen_names.insert(name); | ||
decl_field->setDeclName(ast.CreateIdentifier(name)); | ||
|
This file contains 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 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
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.
Does this make an explicit field out of the base type in the case of inheritance? Can you add a comment here that shows what a simple c++ code would look like, and what we would generate as a result?
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.
Can you add some examples that use multiple inheritance and virtual inheritance?
Also, here is a particularly thorny example which shows when this method of embedding the base within the structure of the parent is going to break down:
C++: https://godbolt.org/z/bM4vrq6fW
C: https://godbolt.org/z/fYarYo5he
See this SO post for more detail: https://stackoverflow.com/questions/52818411/will-the-padding-of-base-class-be-copied-into-the-derived-class