llvm / llvm/llvm-project

[clang-format] [feature-request] Add option to autoreplace class -> struct

Open
#162,223 3 comments 1 reaction 0 assignees View on GitHub
clang-format
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

In my company, coding style completely forbids the use of the `class` keyword.
Unfortunately, there is currently no option in clang-format to automatically enforce or transform this rule.

It would be very useful to add an option to clang-format to automatically replace `class` with `struct`

expected behavior:

```cpp
enum class abc ===> enum struct abc

template ===> template

template class A>
void foo();

===>

template typename A>
void foo();

class A ===> struct A

class A : a, b, c ===> struct A : private a, private b, private c
```

Contributor guide

Open the contributing guide

Research direction

Start by examining clang-format and how it handles the class, enum class, and template forms shown in the issue. Define the option's expected behavior from the examples, including access defaults for transformed base classes, and add coverage demonstrating each requested transformation.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.