ArrayRef<tooling::Range> Ranges,
StringRef FileName, unsigned *Cursor) {
tooling::Replacements Replaces;
- if (!Style.SortIncludes)
+ if (!Style.SortIncludes || Style.DisableFormat)
return Replaces;
if (isLikelyXml(Code))
return Replaces;
#include "FormatTestUtils.h"
#include "clang/Format/Format.h"
#include "llvm/ADT/None.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Debug.h"
#include "gtest/gtest.h"
EXPECT_EQ(Expected, sort(Code, "a.cpp", 1));
}
+TEST_F(SortIncludesTest, DisableFormatDisablesIncludeSorting) {
+ StringRef Sorted = "#include <a.h>\n"
+ "#include <b.h>\n";
+ StringRef Unsorted = "#include <b.h>\n"
+ "#include <a.h>\n";
+ EXPECT_EQ(Sorted, sort(Unsorted));
+ FmtStyle.DisableFormat = true;
+ EXPECT_EQ(Unsorted, sort(Unsorted, "input.cpp", 0));
+}
+
} // end namespace
} // end namespace format
} // end namespace clang