This is an archive of the discontinued LLVM Phabricator instance.

[format][NFC] Use unsigned char as the base of all enums in FormatStyle
ClosedPublic

Authored by njames93 on Dec 23 2020, 4:02 AM.

Details

Summary

This removes alot of unnecessary padding, trimming the size of the struct from 728->608 on 64 bit platforms.

Diff Detail

Event Timeline

njames93 requested review of this revision.Dec 23 2020, 4:02 AM
njames93 created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptDec 23 2020, 4:02 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

We should probably check the docs/tools/dump_format_style.py still works

We should probably check the docs/tools/dump_format_style.py still works

Good catch, I'll update the script to optionally take an underlying type argument. Should that be part of this change, or a parent?

njames93 updated this revision to Diff 313559.Dec 23 2020, 7:53 AM
  • Update dump_format_style script

Only tweaked regex to support enum <name> : <words> ... {
Decided there wasn't much to gain from supporting nested types etc

I don't have any major issues with this other than it makes Format.h a bit more ugly. (there are more ugly and harder to understand pieces of code than this change!)

We'll only normally really have 1 of these in play at any one time, but it is passed around quite a bit on the stack, should we care about the extra space it's taking? (I'm ok if the answer is "yes we should")

I don't have any major issues with this other than it makes Format.h a bit more ugly. (there are more ugly and harder to understand pieces of code than this change!)

We'll only normally really have 1 of these in play at any one time, but it is passed around quite a bit on the stack, should we care about the extra space it's taking? (I'm ok if the answer is "yes we should")

We only keep one instance on the stack in clang-format. But in tools that embed clang format we may keep more than 1 around. In clangd we are hoping to cache format styles for each file(well directory). As these cached items will live on the heap, saving about 16% from the size is worth it.

MyDeveloperDay accepted this revision.Dec 23 2020, 9:50 AM
This revision is now accepted and ready to land.Dec 23 2020, 9:50 AM
HazardyKnusperkeks added a project: Restricted Project.Feb 27 2022, 6:24 AM

This went totally over my head.