Index: clang/lib/Format/WhitespaceManager.cpp =================================================================== --- clang/lib/Format/WhitespaceManager.cpp +++ clang/lib/Format/WhitespaceManager.cpp @@ -909,8 +909,8 @@ if (Style.ColumnLimit == 0) ChangeMaxColumn = UINT_MAX; - else if (Style.ColumnLimit >= Changes[i].TokenLength) - ChangeMaxColumn = Style.ColumnLimit - Changes[i].TokenLength; + else if (Style.ColumnLimit >= Changes[i].Tok->ColumnWidth) + ChangeMaxColumn = Style.ColumnLimit - Changes[i].Tok->ColumnWidth; else ChangeMaxColumn = ChangeMinColumn; Index: clang/unittests/Format/FormatTestComments.cpp =================================================================== --- clang/unittests/Format/FormatTestComments.cpp +++ clang/unittests/Format/FormatTestComments.cpp @@ -2856,6 +2856,13 @@ "int a; //\n"); verifyFormat("/**/ //\n" "int a; //\n"); + + // https://llvm.org/PR48280 + EXPECT_EQ("int ab; // utf8 🐉\n" + "int a; // line\n", + format("int ab; // long 🐉\n" + "int a; // line\n", + getLLVMStyleWithColumns(17))); } TEST_F(FormatTestComments, AlignsBlockCommentDecorations) {