|
@@ -1780,11 +1780,20 @@ tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code,
|
|
for (const auto &Category : Style.IncludeCategories)
|
|
for (const auto &Category : Style.IncludeCategories)
|
|
CategoryRegexs.emplace_back(Category.Regex);
|
|
CategoryRegexs.emplace_back(Category.Regex);
|
|
|
|
|
|
|
|
+ bool FormattingOff = false;
|
|
|
|
+
|
|
for (;;) {
|
|
for (;;) {
|
|
auto Pos = Code.find('\n', SearchFrom);
|
|
auto Pos = Code.find('\n', SearchFrom);
|
|
StringRef Line =
|
|
StringRef Line =
|
|
Code.substr(Prev, (Pos != StringRef::npos ? Pos : Code.size()) - Prev);
|
|
Code.substr(Prev, (Pos != StringRef::npos ? Pos : Code.size()) - Prev);
|
|
- if (!Line.endswith("\\")) {
|
|
|
|
|
|
+
|
|
|
|
+ StringRef Trimmed = Line.trim();
|
|
|
|
+ if (Trimmed == "// clang-format off")
|
|
|
|
+ FormattingOff = true;
|
|
|
|
+ else if (Trimmed == "// clang-format on")
|
|
|
|
+ FormattingOff = false;
|
|
|
|
+
|
|
|
|
+ if (!FormattingOff && !Line.endswith("\\")) {
|
|
if (IncludeRegex.match(Line, &Matches)) {
|
|
if (IncludeRegex.match(Line, &Matches)) {
|
|
StringRef IncludeName = Matches[2];
|
|
StringRef IncludeName = Matches[2];
|
|
unsigned Category;
|
|
unsigned Category;
|