Skip to content

Commit

Permalink
specify custom brace style to fix unions
Browse files Browse the repository at this point in the history
BreakBeforeBraces: Allman apparently includes all styles,
except for AfterUnion (which is false) when using clang-format -dump-config
  • Loading branch information
BhaaLseN committed Jan 5, 2017
1 parent 41101be commit 23d99f2
Show file tree
Hide file tree
Showing 47 changed files with 375 additions and 182 deletions.
14 changes: 13 additions & 1 deletion Source/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,20 @@ AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Allman
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 100
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Common/Arm64Emitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2665,7 +2665,8 @@ void ARM64FloatEmitter::EncodeLoadStoreRegisterOffset(u32 size, bool load, ARM64

void ARM64FloatEmitter::EncodeModImm(bool Q, u8 op, u8 cmode, u8 o2, ARM64Reg Rd, u8 abcdefgh)
{
union {
union
{
u8 hex;
struct
{
Expand Down
6 changes: 4 additions & 2 deletions Source/Core/Common/MathUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ const int frsqrte_expected_dec[] = {

double ApproximateReciprocalSquareRoot(double val)
{
union {
union
{
double valf;
s64 vali;
};
Expand Down Expand Up @@ -178,7 +179,8 @@ double ApproximateReciprocal(double val)
// The workaround for this is to just use namespace std within this function's scope
// That way on real toolchains it will use the std:: variant like normal.
using namespace std;
union {
union
{
double valf;
s64 vali;
};
Expand Down
6 changes: 4 additions & 2 deletions Source/Core/Common/MathUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,16 @@ static const u64 DOUBLE_SIGN = 0x8000000000000000ULL, DOUBLE_EXP = 0x7FF00000000
static const u32 FLOAT_SIGN = 0x80000000, FLOAT_EXP = 0x7F800000, FLOAT_FRAC = 0x007FFFFF,
FLOAT_ZERO = 0x00000000;

union IntDouble {
union IntDouble
{
double d;
u64 i;

explicit IntDouble(u64 _i) : i(_i) {}
explicit IntDouble(double _d) : d(_d) {}
};
union IntFloat {
union IntFloat
{
float f;
u32 i;

Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Common/TraversalProto.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ struct TraversalPacket
{
u8 type;
TraversalRequestId requestId;
union {
union
{
struct
{
u8 ok;
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/ActionReplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ static bool s_disable_logging = false;

struct ARAddr
{
union {
union
{
u32 address;
struct
{
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/Boot/ElfTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ struct Elf32_Rela
struct Elf32_Dyn
{
s32 d_tag;
union {
union
{
u32 d_val;
u32 d_ptr;
} d_un;
Expand Down
9 changes: 6 additions & 3 deletions Source/Core/Core/DSP/DSPCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ struct DSP_Regs
u16 cr;
u16 sr;

union {
union
{
u64 val;
struct
{
Expand All @@ -236,7 +237,8 @@ struct DSP_Regs
};
} prod;

union {
union
{
u32 val;
struct
{
Expand All @@ -245,7 +247,8 @@ struct DSP_Regs
};
} ax[2];

union {
union
{
u64 val;
struct
{
Expand Down
6 changes: 4 additions & 2 deletions Source/Core/Core/FifoPlayer/FifoFileStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ enum

#pragma pack(push, 4)

union FileHeader {
union FileHeader
{
struct
{
u32 fileId;
Expand All @@ -40,7 +41,8 @@ union FileHeader {
u32 rawData[32];
};

union FileFrameInfo {
union FileFrameInfo
{
struct
{
u64 fifoDataOffset;
Expand Down
6 changes: 4 additions & 2 deletions Source/Core/Core/HW/AudioInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ enum
};

// AI Control Register
union AICR {
union AICR
{
AICR() { hex = 0; }
AICR(u32 _hex) { hex = _hex; }
struct
Expand All @@ -90,7 +91,8 @@ union AICR {
};

// AI Volume Register
union AIVR {
union AIVR
{
AIVR() { hex = 0; }
struct
{
Expand Down
9 changes: 6 additions & 3 deletions Source/Core/Core/HW/DSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ enum
};

// UARAMCount
union UARAMCount {
union UARAMCount
{
u32 Hex;
struct
{
Expand All @@ -75,7 +76,8 @@ union UARAMCount {
};

// Blocks are 32 bytes.
union UAudioDMAControl {
union UAudioDMAControl
{
u16 Hex;
struct
{
Expand Down Expand Up @@ -139,7 +141,8 @@ static AudioDMA g_audioDMA;
static ARAM_DMA g_arDMA;
UDSPControl g_dspState;

union ARAM_Info {
union ARAM_Info
{
u16 Hex;
struct
{
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/HW/DSP.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ enum

// UDSPControl
constexpr u16 DSP_CONTROL_MASK = 0x0C07;
union UDSPControl {
union UDSPControl
{
u16 Hex;
struct
{
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/HW/DSPHLE/UCodes/AXStructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ struct PBBiquadFilter
u16 a2;
};

union PBInfImpulseResponseWM {
union PBInfImpulseResponseWM
{
PBLowPassFilter lpf;
PBBiquadFilter biquad;
};
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/HW/DSPHLE/UCodes/AXVoice.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ namespace
#define HILO_TO_32(name) ((name##_hi << 16) | name##_lo)

// Used to pass a large amount of buffers to the mixing function.
union AXBuffers {
union AXBuffers
{
struct
{
int* left;
Expand Down
24 changes: 16 additions & 8 deletions Source/Core/Core/HW/DVDInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ enum
};

// DI Status Register
union UDISR {
union UDISR
{
u32 Hex;
struct
{
Expand All @@ -126,7 +127,8 @@ union UDISR {
};

// DI Cover Register
union UDICVR {
union UDICVR
{
u32 Hex;
struct
{
Expand All @@ -139,7 +141,8 @@ union UDICVR {
UDICVR(u32 _hex) { Hex = _hex; }
};

union UDICMDBUF {
union UDICMDBUF
{
u32 Hex;
struct
{
Expand All @@ -151,7 +154,8 @@ union UDICMDBUF {
};

// DI DMA Address Register
union UDIMAR {
union UDIMAR
{
u32 Hex;
struct
{
Expand All @@ -166,7 +170,8 @@ union UDIMAR {
};

// DI DMA Address Length Register
union UDILENGTH {
union UDILENGTH
{
u32 Hex;
struct
{
Expand All @@ -181,7 +186,8 @@ union UDILENGTH {
};

// DI DMA Control Register
union UDICR {
union UDICR
{
u32 Hex;
struct
{
Expand All @@ -192,7 +198,8 @@ union UDICR {
};
};

union UDIIMMBUF {
union UDIIMMBUF
{
u32 Hex;
struct
{
Expand All @@ -204,7 +211,8 @@ union UDIIMMBUF {
};

// DI Config Register
union UDICFG {
union UDICFG
{
u32 Hex;
struct
{
Expand Down
6 changes: 4 additions & 2 deletions Source/Core/Core/HW/EXI_Channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class CEXIChannel
};

// EXI Status Register - "Channel Parameter Register"
union UEXI_STATUS {
union UEXI_STATUS
{
u32 Hex;
// DO NOT obey the warning and give this struct a name. Things will fail.
struct
Expand All @@ -55,7 +56,8 @@ class CEXIChannel
};

// EXI Control Register
union UEXI_CONTROL {
union UEXI_CONTROL
{
u32 Hex;
struct
{
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/HW/EXI_DeviceAD16.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class CEXIAD16 : public IEXIDevice
read = 0xa2
};

union UAD16Reg {
union UAD16Reg
{
u32 U32;
u32 U8[4];
};
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/HW/EXI_DeviceMic.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class CEXIMic : public IEXIDevice

u32 m_position;
int command;
union UStatus {
union UStatus
{
u16 U16;
u8 U8[2];
struct
Expand Down
Loading

0 comments on commit 23d99f2

Please sign in to comment.