clang 24.0.0git
FormatStyle::IntegerLiteralSeparatorStyle Struct Reference

Separator format of integer literals of different bases. More...

#include "clang/Format/Format.h"

Public Member Functions

bool operator== (const IntegerLiteralSeparatorStyle &R) const
bool operator!= (const IntegerLiteralSeparatorStyle &R) const

Public Attributes

int8_t Binary
 Format separators in binary literals.
int8_t BinaryMinDigitsInsert
 Format separators in binary literals with a minimum number of digits.
int8_t BinaryMaxDigitsRemove
 Remove separators in binary literals with a maximum number of digits.
int8_t Decimal
 Format separators in decimal literals.
int8_t DecimalMinDigitsInsert
 Format separators in decimal literals with a minimum number of digits.
int8_t DecimalMaxDigitsRemove
 Remove separators in decimal literals with a maximum number of digits.
int8_t Hex
 Format separators in hexadecimal literals.
int8_t HexMinDigitsInsert
 Format separators in hexadecimal literals with a minimum number of digits.
int8_t HexMaxDigitsRemove
 Remove separators in hexadecimal literals with a maximum number of digits.

Detailed Description

Separator format of integer literals of different bases.

If negative, remove separators. If 0, leave the literal as is. If positive, insert separators between digits starting from the rightmost digit.

For example, the config below will leave separators in binary literals alone, insert separators in decimal literals to separate the digits into groups of 3, and remove separators in hexadecimal literals.

Binary: 0
Hex: -1
int8_t Binary
Format separators in binary literals.
Definition Format.h:3546
int8_t Decimal
Format separators in decimal literals.
Definition Format.h:3573
int8_t Hex
Format separators in hexadecimal literals.
Definition Format.h:3600
IntegerLiteralSeparatorStyle IntegerLiteralSeparator
Format integer literal separators (‘’ for C/C++ and _` for C#, Java, and JavaScript).
Definition Format.h:3641

You can also specify a minimum number of digits (BinaryMinDigitsInsert, DecimalMinDigitsInsert, and HexMinDigitsInsert) the integer literal must have in order for the separators to be inserted, and a maximum number of digits (BinaryMaxDigitsRemove, DecimalMaxDigitsRemove, and HexMaxDigitsRemove) until the separators are removed. This divides the literals in 3 regions, always without separator (up until including xxxMaxDigitsRemove), maybe with, or without separators (up until excluding xxxMinDigitsInsert), and finally always with separators.

Note
BinaryMinDigits, DecimalMinDigits, and HexMinDigits are deprecated and renamed to BinaryMinDigitsInsert, DecimalMinDigitsInsert, and HexMinDigitsInsert, respectively. \endnote

Definition at line 3538 of file Format.h.

Member Function Documentation

◆ operator!=()

bool clang::format::FormatStyle::IntegerLiteralSeparatorStyle::operator!= ( const IntegerLiteralSeparatorStyle & R) const
inline

Definition at line 3633 of file Format.h.

◆ operator==()

bool clang::format::FormatStyle::IntegerLiteralSeparatorStyle::operator== ( const IntegerLiteralSeparatorStyle & R) const
inline

Definition at line 3623 of file Format.h.

Member Data Documentation

◆ Binary

int8_t clang::format::FormatStyle::IntegerLiteralSeparatorStyle::Binary

Format separators in binary literals.

/* -1: */ b = 0b100111101101;
/* 0: */ b = 0b10011'11'0110'1;
/* 3: */ b = 0b100'111'101'101;
/* 4: */ b = 0b1001'1110'1101;

Definition at line 3546 of file Format.h.

◆ BinaryMaxDigitsRemove

int8_t clang::format::FormatStyle::IntegerLiteralSeparatorStyle::BinaryMaxDigitsRemove

Remove separators in binary literals with a maximum number of digits.

// Binary: 3
// BinaryMinDigitsInsert: 7
// BinaryMaxDigitsRemove: 4
b0 = 0b1011; // Always removed.
b1 = 0b101101; // Not added.
b2 = 0b1'01'101; // Not removed, not corrected.
b3 = 0b1'101'101; // Always added.
b4 = 0b10'1101; // Corrected to 0b101'101.

Definition at line 3566 of file Format.h.

◆ BinaryMinDigitsInsert

int8_t clang::format::FormatStyle::IntegerLiteralSeparatorStyle::BinaryMinDigitsInsert

Format separators in binary literals with a minimum number of digits.

// Binary: 3
// BinaryMinDigitsInsert: 7
b1 = 0b101101;
b2 = 0b1'101'101;

Definition at line 3554 of file Format.h.

◆ Decimal

int8_t clang::format::FormatStyle::IntegerLiteralSeparatorStyle::Decimal

Format separators in decimal literals.

/* -1: */ d = 18446744073709550592ull;
/* 0: */ d = 184467'440737'0'95505'92ull;
/* 3: */ d = 18'446'744'073'709'550'592ull;

Definition at line 3573 of file Format.h.

◆ DecimalMaxDigitsRemove

int8_t clang::format::FormatStyle::IntegerLiteralSeparatorStyle::DecimalMaxDigitsRemove

Remove separators in decimal literals with a maximum number of digits.

// Decimal: 3
// DecimalMinDigitsInsert: 7
// DecimalMaxDigitsRemove: 4
d0 = 2023; // Always removed.
d1 = 123456; // Not added.
d2 = 1'23'456; // Not removed, not corrected.
d3 = 5'000'000; // Always added.
d4 = 1'23'45; // Corrected to 12'345.

Definition at line 3593 of file Format.h.

◆ DecimalMinDigitsInsert

int8_t clang::format::FormatStyle::IntegerLiteralSeparatorStyle::DecimalMinDigitsInsert

Format separators in decimal literals with a minimum number of digits.

// Decimal: 3
// DecimalMinDigitsInsert: 5
d1 = 2023;
d2 = 10'000;

Definition at line 3581 of file Format.h.

◆ Hex

int8_t clang::format::FormatStyle::IntegerLiteralSeparatorStyle::Hex

Format separators in hexadecimal literals.

/* -1: */ h = 0xDEADBEEFDEADBEEFuz;
/* 0: */ h = 0xDEAD'BEEF'DE'AD'BEE'Fuz;
/* 2: */ h = 0xDE'AD'BE'EF'DE'AD'BE'EFuz;

Definition at line 3600 of file Format.h.

◆ HexMaxDigitsRemove

int8_t clang::format::FormatStyle::IntegerLiteralSeparatorStyle::HexMaxDigitsRemove

Remove separators in hexadecimal literals with a maximum number of digits.

// Hex: 2
// HexMinDigitsInsert: 6
// HexMaxDigitsRemove: 4
h0 = 0xAFFE; // Always removed.
h1 = 0xABCDE; // Not added.
h2 = 0xABC'DE; // Not removed, not corrected.
h3 = 0xAB'CD'EF; // Always added.
h4 = 0xABCD'E; // Corrected to 0xA'BC'DE.

Definition at line 3622 of file Format.h.

◆ HexMinDigitsInsert

int8_t clang::format::FormatStyle::IntegerLiteralSeparatorStyle::HexMinDigitsInsert

Format separators in hexadecimal literals with a minimum number of digits.

// Hex: 2
// HexMinDigitsInsert: 6
h1 = 0xABCDE;
h2 = 0xAB'CD'EF;

Definition at line 3609 of file Format.h.


The documentation for this struct was generated from the following file: