Index: clang/lib/Format/IntegerLiteralSeparatorFixer.cpp =================================================================== --- clang/lib/Format/IntegerLiteralSeparatorFixer.cpp +++ clang/lib/Format/IntegerLiteralSeparatorFixer.cpp @@ -44,10 +44,13 @@ std::pair IntegerLiteralSeparatorFixer::process(const Environment &Env, const FormatStyle &Style) { + std::string Suffix("uUlLzZn"); + switch (Style.Language) { case FormatStyle::LK_Cpp: case FormatStyle::LK_ObjC: Separator = '\''; + Suffix.push_back('_'); break; case FormatStyle::LK_CSharp: case FormatStyle::LK_Java: @@ -116,7 +119,7 @@ continue; } const auto Start = Text[0] == '0' ? 2 : 0; - auto End = Text.find_first_of("uUlLzZn"); + auto End = Text.find_first_of(Suffix); if (End == StringRef::npos) End = Length; if (Start > 0 || End < Length) { Index: clang/unittests/Format/IntegerLiteralSeparatorTest.cpp =================================================================== --- clang/unittests/Format/IntegerLiteralSeparatorTest.cpp +++ clang/unittests/Format/IntegerLiteralSeparatorTest.cpp @@ -47,6 +47,13 @@ Style.IntegerLiteralSeparator.Hex = 2; verifyFormat("h = 0xDE'AD'BE'EF'DE'AD'BE'EFuz;", Hex, Style); + const StringRef UDL("u = 0xDEAD'BEEF'DE'AD'BEE'F_u64;"); + verifyFormat("u = 0xDE'AD'BE'EF'DE'AD'BE'EF_u64;", UDL, Style); + Style.IntegerLiteralSeparator.Hex = -1; + verifyFormat("u = 0xDEADBEEFDEADBEEF_u64;", UDL, Style); + Style.IntegerLiteralSeparator.Hex = 0; + verifyFormat(UDL, Style); + verifyFormat("o0 = 0;\n" "o1 = 07;\n" "o5 = 012345",