Index: clang/lib/Format/Format.cpp =================================================================== --- clang/lib/Format/Format.cpp +++ clang/lib/Format/Format.cpp @@ -2307,8 +2307,8 @@ IncludesInBlock.clear(); FirstIncludeBlock = false; } - Prev = Pos + 1; } + Prev = Pos + 1; if (Pos == StringRef::npos || Pos + 1 == Code.size()) break; SearchFrom = Pos + 1; Index: clang/test/Format/line-disable-include-sorting.cpp =================================================================== --- /dev/null +++ clang/test/Format/line-disable-include-sorting.cpp @@ -0,0 +1,13 @@ +// RUN: grep -Ev "// *[A-Z-]+:" %s \ +// RUN: | clang-format -style="{BasedOnStyle: LLVM, SortIncludes: true}" \ +// RUN: | FileCheck -strict-whitespace %s +// CHECK: {{^//\ clang-format\ off$}} +// CHECK-NEXT: {{^#include\ $}} +// CHECK-NEXT: {{^//\ clang-format\ on$}} +// CHECK-NEXT: {{^#include\ $}} +// CHECK-NEXT: {{^#include\ $}} +// clang-format off +#include +// clang-format on +#include +#include