Index: clang/lib/Format/WhitespaceManager.cpp =================================================================== --- clang/lib/Format/WhitespaceManager.cpp +++ clang/lib/Format/WhitespaceManager.cpp @@ -1430,10 +1430,14 @@ } // FIXME: This assert should hold if we computed the column correctly. // assert((int)C.StartOfTokenColumn >= C.Spaces); - appendIndentText( - ReplacementText, C.Tok->IndentLevel, std::max(0, C.Spaces), - std::max((int)C.StartOfTokenColumn, C.Spaces) - std::max(0, C.Spaces), - C.IsAligned); + unsigned Spaces = std::max(0, C.Spaces); + if (Style.UseTab == FormatStyle::UT_Never) { + ReplacementText.append(Spaces, ' '); + } else { + appendIndentText(ReplacementText, C.Tok->IndentLevel, Spaces, + std::max((int)C.StartOfTokenColumn, C.Spaces) - Spaces, + C.IsAligned); + } ReplacementText.append(C.CurrentLinePrefix); storeReplacement(C.OriginalWhitespaceRange, ReplacementText); }