Refactor: Replace custom getOrigin() method with existing getOldInput… - #1585
Conversation
Parth (parth-07)
left a comment
There was a problem hiding this comment.
Can you please improve the commit message here? This resource might be helpful: https://cbea.ms/git-commit/
0186baf to
8185108
Compare
| I = CommonSection->getOrigin()->getInput(); | ||
| IsCommonSection = true; | ||
|
|
||
| if (Section->hasOldInputFile()) { |
There was a problem hiding this comment.
Were we previously using old input file for non-common sections?
There was a problem hiding this comment.
No, we were not, but as I variable is only used for diagnostic outputs, so it is better to use origin file only irrespective of common sections.
There was a problem hiding this comment.
A refactoring patch should not introduce functionality change, even a diagnostic change. If you think this change is helpful, can you open a separate issue to discuss it?
There was a problem hiding this comment.
I have fixed and opened a seperate issue for the change.
|
There are multiple commits and some of them are not signed. Please add all changes into a single commit since the fix is small enough. |
| InputFile *getOrigin() const { return Origin; } | ||
| bool hasOldInputFile() const override { return Origin != nullptr; } | ||
|
|
||
| InputFile *getOldInputFile() const override { return Origin; } |
There was a problem hiding this comment.
probably another TODO is, rename getOldInputFile function to
getPreLtoInputFile or getOriginalInputFile ?
CommonELFSection had a custom getOrigin() method while other sections
used the virtual getOldInputFile(). This forced type-specific code:
if (auto *CS = dyn_cast<CommonELFSection>(sect))
input = CS->getOrigin();
if (sect->getOldInputFile())
input = sect->getOldInputFile();
Now CommonELFSection overrides getOldInputFile(), enabling uniform code:
if (sect->hasOldInputFile())
input = sect->getOldInputFile();
Changes:
- Add hasOldInputFile/getOldInputFile overrides to CommonELFSection
- Remove redundant getOrigin method
- Simplify ObjectBuilder, SectionMap, GarbageCollection call sites
- Replace dyn_cast + type-specific calls with polymorphic interface
Resolves qualcomm#1300
Signed-off-by: Rachit Mehta <rachmeht@qti.qualcomm.com>
e022705 to
3378cf9
Compare
CommonELFSection had a custom getOrigin() method while other sections
used the virtual getOldInputFile(). This forced type-specific code:
Now CommonELFSection overrides getOldInputFile(), enabling uniform code:
Changes:
Resolves #1300