44std::pair<tooling::Replacements, unsigned>
47 switch (Style.Language) {
61 const auto &Option = Style.IntegerLiteralSeparator;
62 const auto Binary = Option.Binary;
63 const auto Decimal = Option.Decimal;
64 const auto Hex = Option.Hex;
65 const bool SkipBinary =
Binary == 0;
66 const bool SkipDecimal =
Decimal == 0;
67 const bool SkipHex =
Hex == 0;
69 if (SkipBinary && SkipDecimal && SkipHex)
72 const auto BinaryMinDigits =
73 std::max((
int)Option.BinaryMinDigits,
Binary + 1);
74 const auto DecimalMinDigits =
75 std::max((
int)Option.DecimalMinDigits,
Decimal + 1);
76 const auto HexMinDigits = std::max((
int)Option.HexMinDigits,
Hex + 1);
78 const auto &SourceMgr =
Env.getSourceManager();
81 const auto ID =
Env.getFileID();
83 Lexer Lex(
ID, SourceMgr.getBufferOrFake(
ID), SourceMgr, LangOpts);
94 auto Text = StringRef(SourceMgr.getCharacterData(Location), Length);
95 if (Tok.
is(tok::comment)) {
102 if (
Skip || Tok.
isNot(tok::numeric_constant) ||
Text[0] ==
'.' ||
111 if ((IsBase2 && SkipBinary) || (IsBase10 && SkipDecimal) ||
120 Pos != StringRef::npos) {
125 if ((IsBase10 &&
Text.find_last_of(
".eEfFdDmM") != StringRef::npos) ||
126 (IsBase16 &&
Text.find_last_of(
".pP") != StringRef::npos)) {
129 const auto Start =
Text[0] ==
'0' ? 2 : 0;
130 auto End =
Text.find_first_of(
"uUlLzZn", Start);
131 if (End == StringRef::npos)
133 if (Start > 0 || End < Length) {
134 Length = End - Start;
138 auto MinDigits = DecimalMinDigits;
141 MinDigits = BinaryMinDigits;
142 }
else if (IsBase16) {
143 DigitsPerGroup =
Hex;
144 MinDigits = HexMinDigits;
146 const auto SeparatorCount =
Text.count(Separator);
147 const int DigitCount = Length - SeparatorCount;
148 const bool RemoveSeparator = DigitsPerGroup < 0 || DigitCount < MinDigits;
149 if (RemoveSeparator && SeparatorCount == 0)
151 if (!RemoveSeparator && SeparatorCount > 0 &&
152 checkSeparator(
Text, DigitsPerGroup)) {
155 const auto &Formatted =