[llvm] r257951 - [Orc] Replace switch cases with a macro.
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 19 12:10:35 PST 2016
Minor, but could you add a #undef after the switch to make the scope of
the macro explicit?
Philip
On 01/15/2016 03:19 PM, Lang Hames via llvm-commits wrote:
> Author: lhames
> Date: Fri Jan 15 17:19:06 2016
> New Revision: 257951
>
> URL: http://llvm.org/viewvc/llvm-project?rev=257951&view=rev
> Log:
> [Orc] Replace switch cases with a macro.
>
> The cases of this switch are all perfectly regular (except for the first case).
> A macro is more readable here.
>
> Thanks to Dave Blaikie for the suggestion.
>
> Modified:
> llvm/trunk/lib/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.cpp
>
> Modified: llvm/trunk/lib/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.cpp?rev=257951&r1=257950&r2=257951&view=diff
> ==============================================================================
> --- llvm/trunk/lib/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.cpp (original)
> +++ llvm/trunk/lib/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.cpp Fri Jan 15 17:19:06 2016
> @@ -9,6 +9,10 @@
>
> #include "llvm/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.h"
>
> +#define PROCNAME(X) \
> + case X ## Id: \
> + return #X
> +
> namespace llvm {
> namespace orc {
> namespace remote {
> @@ -17,68 +21,37 @@ const char *OrcRemoteTargetRPCAPI::getJI
> switch (Id) {
> case InvalidId:
> return "*** Invalid JITProcId ***";
> - case CallIntVoidId:
> - return "CallIntVoid";
> - case CallIntVoidResponseId:
> - return "CallIntVoidResponse";
> - case CallMainId:
> - return "CallMain";
> - case CallMainResponseId:
> - return "CallMainResponse";
> - case CallVoidVoidId:
> - return "CallVoidVoid";
> - case CallVoidVoidResponseId:
> - return "CallVoidVoidResponse";
> - case CreateRemoteAllocatorId:
> - return "CreateRemoteAllocator";
> - case CreateIndirectStubsOwnerId:
> - return "CreateIndirectStubsOwner";
> - case DeregisterEHFramesId:
> - return "DeregisterEHFrames";
> - case DestroyRemoteAllocatorId:
> - return "DestroyRemoteAllocator";
> - case DestroyIndirectStubsOwnerId:
> - return "DestroyIndirectStubsOwner";
> - case EmitIndirectStubsId:
> - return "EmitIndirectStubs";
> - case EmitIndirectStubsResponseId:
> - return "EmitIndirectStubsResponse";
> - case EmitResolverBlockId:
> - return "EmitResolverBlock";
> - case EmitTrampolineBlockId:
> - return "EmitTrampolineBlock";
> - case EmitTrampolineBlockResponseId:
> - return "EmitTrampolineBlockResponse";
> - case GetSymbolAddressId:
> - return "GetSymbolAddress";
> - case GetSymbolAddressResponseId:
> - return "GetSymbolAddressResponse";
> - case GetRemoteInfoId:
> - return "GetRemoteInfo";
> - case GetRemoteInfoResponseId:
> - return "GetRemoteInfoResponse";
> - case ReadMemId:
> - return "ReadMem";
> - case ReadMemResponseId:
> - return "ReadMemResponse";
> - case RegisterEHFramesId:
> - return "RegisterEHFrames";
> - case ReserveMemId:
> - return "ReserveMem";
> - case ReserveMemResponseId:
> - return "ReserveMemResponse";
> - case RequestCompileId:
> - return "RequestCompile";
> - case RequestCompileResponseId:
> - return "RequestCompileResponse";
> - case SetProtectionsId:
> - return "SetProtections";
> - case TerminateSessionId:
> - return "TerminateSession";
> - case WriteMemId:
> - return "WriteMem";
> - case WritePtrId:
> - return "WritePtr";
> + PROCNAME(CallIntVoid);
> + PROCNAME(CallIntVoidResponse);
> + PROCNAME(CallMain);
> + PROCNAME(CallMainResponse);
> + PROCNAME(CallVoidVoid);
> + PROCNAME(CallVoidVoidResponse);
> + PROCNAME(CreateRemoteAllocator);
> + PROCNAME(CreateIndirectStubsOwner);
> + PROCNAME(DeregisterEHFrames);
> + PROCNAME(DestroyRemoteAllocator);
> + PROCNAME(DestroyIndirectStubsOwner);
> + PROCNAME(EmitIndirectStubs);
> + PROCNAME(EmitIndirectStubsResponse);
> + PROCNAME(EmitResolverBlock);
> + PROCNAME(EmitTrampolineBlock);
> + PROCNAME(EmitTrampolineBlockResponse);
> + PROCNAME(GetSymbolAddress);
> + PROCNAME(GetSymbolAddressResponse);
> + PROCNAME(GetRemoteInfo);
> + PROCNAME(GetRemoteInfoResponse);
> + PROCNAME(ReadMem);
> + PROCNAME(ReadMemResponse);
> + PROCNAME(RegisterEHFrames);
> + PROCNAME(ReserveMem);
> + PROCNAME(ReserveMemResponse);
> + PROCNAME(RequestCompile);
> + PROCNAME(RequestCompileResponse);
> + PROCNAME(SetProtections);
> + PROCNAME(TerminateSession);
> + PROCNAME(WriteMem);
> + PROCNAME(WritePtr);
> };
> return nullptr;
> }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list