This is an archive of the discontinued LLVM Phabricator instance.

Update ARM and x86 ArchHandler to match 64bits counterparts. NFC
ClosedPublic

Authored by Jean-Daniel on Feb 13 2015, 6:46 AM.

Details

Summary

Define an explicit type for arch specific reference kind and use it in switch statement to make the compiler emit warnings if some case is not cover.
It will help to catch such errors when we add new mach-o reference kind.

Diff Detail

Repository
rL LLVM

Event Timeline

Jean-Daniel retitled this revision from to Update ARM and x86 ArchHandler to match 64bits counterparts. NFC.
Jean-Daniel updated this object.
Jean-Daniel edited the test plan for this revision. (Show Details)
Jean-Daniel added a reviewer: kledzik.
Jean-Daniel set the repository for this revision to rL LLVM.
Jean-Daniel added a project: lld.
Jean-Daniel added a subscriber: Unknown Object (MLST).

not sure if its common coding practice to use return instead of break in switch statements.

lib/ReaderWriter/MachO/ArchHandler_arm.cpp
916

There is an assert at line 911, that takes care of making sure all the kinds are specific to ARM, no ?

not sure if its common coding practice to use return instead of break in switch statements.

I don't know if this is a common practice but it matches the x86_64 and ARM64 ArchHandlers.

lib/ReaderWriter/MachO/ArchHandler_arm.cpp
916

assert are runtime error and are not a replacement for proper compile time warning IMHO.

Jean-Daniel added inline comments.Feb 13 2015, 7:07 AM
lib/ReaderWriter/MachO/ArchHandler_arm.cpp
916

Sorry I misread the comment.
The assert check the reference kind family, but it does not guarantee that the following switch has a case to handle it. The problem is when we add new reference kinds, we want to make sure that they are properly handled in all switch() statements.

shankarke accepted this revision.Feb 13 2015, 7:30 AM
shankarke added a reviewer: shankarke.

Please wait for Nick's review too.

lib/ReaderWriter/MachO/ArchHandler_arm.cpp
916

LGTM.

This revision is now accepted and ready to land.Feb 13 2015, 7:30 AM
Jean-Daniel closed this revision.Feb 14 2015, 12:36 AM