Mark UNREACHABLE with intrinsics
This commit is contained in:
parent
6aa1d13508
commit
81e299f00c
@ -318,6 +318,5 @@ float cNoteEntity::PitchFromNote(unsigned char a_Pitch)
|
||||
case 23: return 1.887748625363387f;
|
||||
case 24: return 2.0f;
|
||||
}
|
||||
|
||||
UNREACHABLE("Converted unknown pitch value");
|
||||
}
|
||||
|
@ -132,8 +132,7 @@ private:
|
||||
case BLOCK_FACE_YM: return 0x0;
|
||||
case BLOCK_FACE_NONE:
|
||||
{
|
||||
ASSERT(!"Unhandled block face!");
|
||||
return 0x0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
UNREACHABLE("Unsupported block face");
|
||||
@ -265,10 +264,9 @@ private:
|
||||
case BLOCK_FACE_YP: return { 0.5, 0, 0.5 };
|
||||
case BLOCK_FACE_NONE:
|
||||
{
|
||||
ASSERT(!"Unhandled block face!");
|
||||
return { 0, 0, 0 };
|
||||
break;
|
||||
}
|
||||
}
|
||||
UNREACHABLE(!"Unhandled block face!");
|
||||
UNREACHABLE("Unhandled block face!");
|
||||
}
|
||||
} ;
|
||||
|
@ -28,8 +28,7 @@ public:
|
||||
case BLOCK_FACE_YM:
|
||||
case BLOCK_FACE_YP:
|
||||
{
|
||||
ASSERT(!"Unknown face");
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
UNREACHABLE("Unsupported block face");
|
||||
|
@ -936,6 +936,5 @@ const cBlockHandler & cBlockHandler::For(BLOCKTYPE a_BlockType)
|
||||
case E_BLOCK_NUMBER_OF_TYPES:
|
||||
case E_BLOCK_UNFINISHED: return BlockAirHandler;
|
||||
}
|
||||
|
||||
UNREACHABLE("Getting handler for unexpected block type");
|
||||
}
|
||||
|
@ -74,8 +74,7 @@ private:
|
||||
|
||||
case BLOCK_FACE_NONE:
|
||||
{
|
||||
ASSERT(!"Unhandled block face!");
|
||||
return a_Meta | 0xC; // No idea, give a special meta
|
||||
break;
|
||||
}
|
||||
}
|
||||
UNREACHABLE("Unsupported block face");
|
||||
|
@ -70,7 +70,6 @@ private:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
UNREACHABLE("Unsupported block face");
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,6 @@ const char * ClickActionToString(int a_ClickAction)
|
||||
case caRightPaintEnd: return "caRightPaintEnd";
|
||||
case caMiddlePaintEnd: return "caMiddlePaintEnd";
|
||||
case caDblClick: return "caDblClick";
|
||||
|
||||
case caUnknown: return "caUnknown";
|
||||
}
|
||||
UNREACHABLE("Unknown click action");
|
||||
|
@ -287,8 +287,7 @@ double cStructGenTrees::GetNumTrees(
|
||||
case biVariant:
|
||||
case biNumVariantBiomes:
|
||||
{
|
||||
ASSERT(!"Invalid biome in cStructGenTrees::GetNumTrees");
|
||||
return 0.0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
UNREACHABLE("Unsupported biome");
|
||||
|
@ -35,11 +35,15 @@
|
||||
// The CRT has a definition for this operator new that stores the debugging info for leak-finding later.
|
||||
#endif
|
||||
|
||||
#define UNREACHABLE_INTRINSIC __assume(false)
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
|
||||
// TODO: Can GCC explicitly mark classes as abstract (no instances can be created)?
|
||||
#define abstract
|
||||
|
||||
#define UNREACHABLE_INTRINSIC __builtin_unreachable()
|
||||
|
||||
#else
|
||||
|
||||
#error "You are using an unsupported compiler, you might need to #define some stuff here for your compiler"
|
||||
@ -271,8 +275,12 @@ template class SizeChecker<UInt8, 1>;
|
||||
|
||||
#endif // else TEST_GLOBALS
|
||||
|
||||
/** Use to mark code that should be impossible to reach. */
|
||||
#define UNREACHABLE(x) do { FLOGERROR("Hit unreachable code: {0}, file {1}, line {2}", #x, __FILE__, __LINE__); std::abort(); } while (false)
|
||||
// Use to mark code that should be impossible to reach.
|
||||
#ifdef NDEBUG
|
||||
#define UNREACHABLE(x) UNREACHABLE_INTRINSIC
|
||||
#else
|
||||
#define UNREACHABLE(x) ( FLOGERROR("Hit unreachable code: {0}, file {1}, line {2}", #x, __FILE__, __LINE__), std::abort(), 0)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@ -41,8 +41,7 @@ int cMobCensus::GetCapMultiplier(cMonster::eFamily a_MobFamily)
|
||||
case cMonster::mfNoSpawn:
|
||||
case cMonster::mfUnhandled:
|
||||
{
|
||||
ASSERT(!"Unhandled mob family");
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
UNREACHABLE("Unsupported mob family");
|
||||
|
@ -118,7 +118,6 @@ void cChunkDataSerializer::SendToClients(const int a_ChunkX, const int a_ChunkZ,
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
UNREACHABLE("Unknown chunk data serialization version");
|
||||
}
|
||||
|
||||
|
@ -1053,7 +1053,7 @@ void cProtocol_1_10_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_
|
||||
case mtZombieHorse:
|
||||
{
|
||||
// Todo: Mobs not added yet. Grouped ones have the same metadata
|
||||
UNREACHABLE("cProtocol_1_10::WriteMobMetadata: received unimplemented type");
|
||||
ASSERT(!"cProtocol_1_10::WriteMobMetadata: received unimplemented type");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1072,10 +1072,7 @@ void cProtocol_1_10_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_
|
||||
// Entities without additional metadata
|
||||
break;
|
||||
}
|
||||
case mtInvalidType:
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
default: UNREACHABLE("cProtocol_1_10::WriteMobMetadata: received mob of invalid type");
|
||||
} // switch (a_Mob.GetType())
|
||||
}
|
||||
|
@ -1241,7 +1241,7 @@ void cProtocol_1_11_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_
|
||||
case mtVindicator:
|
||||
{
|
||||
// Todo: Mobs not added yet. Grouped ones have the same metadata
|
||||
UNREACHABLE("cProtocol_1_11::WriteMobMetadata: received unimplemented type");
|
||||
ASSERT(!"cProtocol_1_11::WriteMobMetadata: received unimplemented type");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1260,10 +1260,7 @@ void cProtocol_1_11_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_
|
||||
// Mobs without additional metadata
|
||||
break;
|
||||
}
|
||||
case mtInvalidType:
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
default: UNREACHABLE("cProtocol_1_11::WriteMobMetadata: received mob of invalid type");
|
||||
} // switch (a_Mob.GetType())
|
||||
}
|
||||
|
@ -957,7 +957,7 @@ void cProtocol_1_12::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo
|
||||
case mtVindicator:
|
||||
{
|
||||
// Todo: Mobs not added yet. Grouped ones have the same metadata
|
||||
UNREACHABLE("cProtocol_1_12::WriteMobMetadata: received unimplemented type");
|
||||
ASSERT(!"cProtocol_1_12::WriteMobMetadata: received unimplemented type");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -970,10 +970,6 @@ void cProtocol_1_12::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo
|
||||
break;
|
||||
}
|
||||
|
||||
case mtInvalidType:
|
||||
{
|
||||
break;
|
||||
}
|
||||
default: UNREACHABLE("cProtocol_1_12::WriteMobMetadata: received mob of invalid type");
|
||||
} // switch (a_Mob.GetType())
|
||||
}
|
||||
|
@ -463,7 +463,6 @@ UInt32 cProtocol_1_13::GetProtocolMobType(eMonsterType a_MobType)
|
||||
case mtZombiePigman: return 53;
|
||||
case mtZombieHorse: return 88;
|
||||
case mtZombieVillager: return 89;
|
||||
|
||||
default: return 0;
|
||||
}
|
||||
UNREACHABLE("Unsupported mob type");
|
||||
@ -599,7 +598,6 @@ UInt8 cProtocol_1_13::GetEntityMetadataID(EntityMetadata a_Metadata)
|
||||
case EntityMetadata::AbstractSkeletonArmsSwinging:
|
||||
case EntityMetadata::ZombieUnusedWasType: break;
|
||||
}
|
||||
|
||||
UNREACHABLE("Retrieved invalid metadata for protocol");
|
||||
}
|
||||
|
||||
@ -631,7 +629,6 @@ UInt8 cProtocol_1_13::GetEntityMetadataID(EntityMetadataType a_FieldType)
|
||||
case EntityMetadataType::OptVarInt: return 17;
|
||||
case EntityMetadataType::Pose: return 18;
|
||||
}
|
||||
|
||||
UNREACHABLE("Translated invalid metadata type for protocol");
|
||||
}
|
||||
|
||||
@ -1307,10 +1304,9 @@ void cProtocol_1_13::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo
|
||||
case mtVindicator:
|
||||
|
||||
case mtHusk:
|
||||
|
||||
{
|
||||
// Todo: Mobs not added yet. Grouped ones have the same metadata
|
||||
UNREACHABLE("cProtocol_1_13::WriteMobMetadata: received unimplemented type");
|
||||
ASSERT(!"cProtocol_1_13::WriteMobMetadata: received unimplemented type");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1331,10 +1327,6 @@ void cProtocol_1_13::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo
|
||||
break;
|
||||
}
|
||||
|
||||
case mtInvalidType:
|
||||
{
|
||||
break;
|
||||
}
|
||||
default: UNREACHABLE("cProtocol_1_13::WriteMobMetadata: received mob of invalid type");
|
||||
} // switch (a_Mob.GetType())
|
||||
}
|
||||
|
@ -3848,7 +3848,7 @@ void cProtocol_1_8_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_M
|
||||
case mtZombieHorse:
|
||||
{
|
||||
// Todo: Mobs not added yet. Grouped ones have the same metadata
|
||||
UNREACHABLE("cProtocol_1_8::WriteMobMetadata: received unimplemented type");
|
||||
ASSERT(!"cProtocol_1_8::WriteMobMetadata: received unimplemented type");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -3865,10 +3865,7 @@ void cProtocol_1_8_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_M
|
||||
// Allowed mobs without additional metadata
|
||||
break;
|
||||
}
|
||||
case mtInvalidType:
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
default: UNREACHABLE("cProtocol_1_8::WriteMobMetadata: received mob of invalid type");
|
||||
} // switch (a_Mob.GetType())
|
||||
}
|
||||
@ -4029,7 +4026,7 @@ UInt8 cProtocol_1_8_0::GetProtocolEntityType(const cEntity & a_Entity)
|
||||
case Type::etPlayer:
|
||||
case Type::etMonster:
|
||||
case Type::etExpOrb:
|
||||
case Type::etPainting: UNREACHABLE("Tried to spawn an unhandled entity");
|
||||
case Type::etPainting: break;
|
||||
}
|
||||
UNREACHABLE("Unhandled entity kind");
|
||||
}
|
||||
|
@ -2150,7 +2150,7 @@ void cProtocol_1_9_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_M
|
||||
case mtShulker:
|
||||
{
|
||||
// Todo: Mobs not added yet. Grouped ones have the same metadata
|
||||
UNREACHABLE("cProtocol_1_9::WriteMobMetadata: received unimplemented type");
|
||||
ASSERT(!"cProtocol_1_9::WriteMobMetadata: received unimplemented type");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2167,10 +2167,7 @@ void cProtocol_1_9_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_M
|
||||
// Entities without additional metadata
|
||||
break;
|
||||
}
|
||||
case mtInvalidType:
|
||||
{
|
||||
|
||||
}
|
||||
default: UNREACHABLE("cProtocol_1_9::WriteMobMetadata: received mob of invalid type");
|
||||
} // switch (a_Mob.GetType())
|
||||
}
|
||||
|
@ -133,7 +133,6 @@ std::string_view NamespaceSerializer::From(const Statistic a_ID)
|
||||
case Statistic::AchBreedCow: return "cuberite:achievement.breedCow";
|
||||
case Statistic::AchDiamondsToYou: return "cuberite:achievement.diamondsToYou";
|
||||
}
|
||||
|
||||
UNREACHABLE("Tried to save unhandled statistic");
|
||||
}
|
||||
|
||||
@ -216,7 +215,6 @@ std::string_view NamespaceSerializer::From(eMonsterType a_ID)
|
||||
case mtZombieVillager: return "zombie_villager";
|
||||
case mtInvalidType: break;
|
||||
}
|
||||
|
||||
UNREACHABLE("Tried to save unknown monster type");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user