style: apply automated formatting baseline with clang-format#2638
style: apply automated formatting baseline with clang-format#2638DevGeniusCode wants to merge 7 commits intoTheSuperHackers:mainfrom
Conversation
|
| Filename | Overview |
|---|---|
| .clang-format | Introduces the clang-format baseline config; two P1 issues: Standard is still c++20 (not c++03 as promised in-thread), and AllowShortBlocksOnASingleLine: Always conflicts with the team's debugger-breakpoint style rule. |
| Core/GameEngine/Source/Common/System/AsciiString.cpp | Formatting-only changes (Allman braces, tab indentation); no logic changes detected. |
| Core/GameEngine/Source/Common/System/GameMemory.cpp | Formatting-only changes; tab/brace style applied uniformly with no logic alterations. |
| Core/GameEngine/Source/GameClient/GUI/GameWindow.cpp | Formatting-only changes (Allman braces, indentation); no behavioral differences introduced. |
| Core/GameEngine/Source/GameNetwork/Connection.cpp | Formatting-only changes; network logic untouched. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Developer runs clang-format] --> B{.clang-format config}
B --> C["Standard: c++20 ⚠️ Should be c++03"]
B --> D["ColumnLimit: 0 — no line wrapping"]
B --> E["BreakBeforeBraces: Custom — Allman style"]
B --> F["AllowShortBlocksOnASingleLine: Always ⚠️ Conflicts with rule 16b9b669"]
C --> G["C++20 parser may collapse nested template brackets"]
G --> H["VC6 template compilation may break"]
F --> I["Single-line braced blocks preserved by formatter"]
I --> J["Violates debugger-breakpoint placement rule"]
E --> K["AfterControlStatement: Always — braces on new lines"]
D --> L["Manual line breaks preserved across 283 files"]
Prompt To Fix All With AI
This is a comment left during a code review.
Path: .clang-format
Line: 23
Comment:
**`Standard: c++20` not updated despite in-thread acknowledgement**
The reply to the previous reviewer confirmed this was "changed to c++03", but the file still reads `Standard: c++20`. This matters beyond style: the thread also dismissed the missing `SpacesInAngles: Leave` concern by saying "is fine by Standard: c++03" — that reasoning only holds if the standard is actually set to c++03. With c++20 still in effect, the formatter may collapse `> >` to `>>` in template declarations, breaking compilation on VC6/early MSVC.
```suggestion
Standard: c++03
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: .clang-format
Line: 70
Comment:
**`AllowShortBlocksOnASingleLine: Always` conflicts with the codebase's debugger-breakpoint rule**
The team's coding standard requires that if/else/for/while statement bodies always appear on a separate line from the condition, specifically to allow precise debugger breakpoint placement. With `AllowShortBlocksOnASingleLine: Always`, clang-format will not split existing single-line braced blocks (e.g. `if (a) { b; }`), leaving them on one line indefinitely — directly conflicting with this rule. The safer value is `Empty`, which only collapses genuinely empty blocks (`{}`) while leaving single-statement blocks to be expanded by `AfterControlStatement: Always`.
**Rule Used:** Always place if/else/for/while statement bodies on... ([source](https://app.greptile.com/review/custom-context?memory=16b9b669-b823-49be-ba5b-2bd30ff3ba6d))
**Learned From**
[TheSuperHackers/GeneralsGameCode#2067](https://github.com/TheSuperHackers/GeneralsGameCode/pull/2067#discussion_r2706274626)
How can I resolve this? If you propose a fix, please make it concise.Reviews (4): Last reviewed commit: "style: standardize assignment operator i..." | Re-trigger Greptile
a9d279e to
9ddb58a
Compare
|
There are still a few formatting improvements I haven’t addressed in this pass, such as consecutive assignment alignment. Current (Before): AudioAffect_Music = 0x01,
AudioAffect_Sound = 0x02,
AudioAffect_Sound3D = 0x04,
AudioAffect_All = (Music | Sound | Sound3D),Target (After): AudioAffect_Music = 0x01,
AudioAffect_Sound = 0x02,
AudioAffect_Sound3D = 0x04,
AudioAffect_All = (Music | Sound | Sound3D),If there is interest, I can implement it |
| { \ | ||
| DebugLogRaw m; \ | ||
| } \ | ||
| } while (0) |
There was a problem hiding this comment.
Sounds like an argument for indenting with spaces to me, but I realise that will bloat the diff significantly so isn't really in scopde for the first pass.
There was a problem hiding this comment.
The issue is that the backslashes shouldn't be aligned with spaces in the first place.
This is not a github only problem, but every IDE that has a tab size setting other then 2.
There was a problem hiding this comment.
They can be aligned to the right with spaces when leading tabs become spaces.
There was a problem hiding this comment.
It is also possible to disable the alignment
before
#define DEBUG_LOG_LEVEL(l, m) \
do..........................\
{...........................\
if (l & DebugLevelMask)...\after
#define DEBUG_LOG_LEVEL(l, m) \
do \
{ \
if (l & DebugLevelMask) \
{ \
DebugLog m; \
} \
} while (0)There was a problem hiding this comment.
Unless tabs turn into spaces, I think disabling alignment is the best approach.
I think in general, complex logic shouldn't be in a macro, but in an actual function.
Core\GameEngine)Core\GameEngine)
This is good. |
Core\GameEngine)|
Updated |

Prerequisites: Please Merge First
This PR is the final step of the formatting baseline. It depends on two preliminary structural PRs that must be merged first to ensure a clean, 100% automated formatting pass without breaking VC6 compilation:
>>merging in C++98.Objective
This PR introduces a minimalist, non-destructive
.clang-formatbaseline. To make this easy to review and discuss, I have scoped the formatting only to the.\Core\GameEnginedirectory.The "Do No Harm" Approach
The primary goal of this configuration is to avoid the "destructive" behavior of standard formatters.
ColumnLimit: 0: Automatic line wrapping is completely disabled. Clang-format will respect our manual line breaks and will not pack or split arguments unexpectedly.What is being formatted?
To establish a consistent baseline, the formatter enforces a few core rules:
Why this change was made -now-:
clang-formatfundamentally requires a brace style to function; it cannot simply "ignore" braces even on a pure whitespace pass. Since running the tool was inevitably going to touch braces and affect line counts anyway, I decided to "go all in" and establish a fully consistent style across the board, rather than trying to fight the tool to maintain an inconsistent legacy mix.void* ptr).AlignTrailingComments: false) with a fixed 5-space offset. This prevents "diff pollution" (the ripple effect where adding one long function name forces all surrounding comments to shift).\) are left-aligned (AlignEscapedNewlines: DontAlign) with a single space. This eliminates the "mixed whitespace" anti-pattern and ensures macros render perfectly straight in GitHub and all IDEs, regardless of the user's tab width setting.Legacy / VC6 Compatibility
A lot of effort went into making sure this doesn't break our legacy support:
Standard: c++20to correctly parse modern syntax while maintaining VC6 compatibility structurally.AttributeMacrosandMacros) to safely parse ourCPP_11enum macros without breaking the formatting tree.AllowShortBlocksOnASingleLine: Alwaysso macros and empty stubs aren't vertically bloated.Future Phases (Minimizing the Initial Diff)
Please note that several settings in this baseline (such as
SortIncludes: false,AllowShortFunctionsOnASingleLine: All, andAllowShortBlocksOnASingleLine: Always) are intentionally included purely to minimize the initial diff and avoid overwhelming changes.