This is an archive of the discontinued LLVM Phabricator instance.

[NFC] Simplifying the condition which kind of MCFragment doesn't need to handle fixup
AbandonedPublic

Authored by Jim on Jan 6 2020, 9:55 PM.

Details

Summary
  1. MCCompactEncodedInstFragment is a subclass of MCEncodedFragment.
  2. Add missing kind MCFragment::FT_CVDefRange into MCEncodedFragment's classof.

Diff Detail

Event Timeline

Jim created this revision.Jan 6 2020, 9:55 PM
Jim added a reviewer: majnemer.Jan 8 2020, 6:12 PM

Did you audit the other uses of dyn_cast<MCEncodedFragment>

llvm/include/llvm/MC/MCFragment.h
139

This seems obvious given the inheritance structure.

220

MCEncodedFragmentWithFixups::classof is wrong; it allows incorrect casts.

Jim marked 2 inline comments as done.Jan 21 2020, 1:10 AM
Jim added inline comments.
llvm/include/llvm/MC/MCFragment.h
139

MCCVDefRangeFragment inherits MCEncodedFragmentWithFixups.
MCEncodedFragmentWithFixups inherits MCEncodedFragmentWithContents.
MCEncodedFragmentWithContents inherits MCEncodedFragment.

So MCCVDefRangeFragment is kind of MCEncodedFragment.

220

I don't understand why it is wrong? Thanks

Did you audit the other uses of dyn_cast<MCEncodedFragment>?

llvm/include/llvm/MC/MCFragment.h
220

MCEncodedFragmentWithFixups is a template; the specific fragment kinds only inherit from one specific instantiation of the template.

Jim abandoned this revision.Jul 5 2023, 7:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 5 2023, 7:30 PM