diff options
| author | Daniel Jasper <djasper@google.com> | 2015-11-21 09:17:08 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2015-11-21 09:17:08 +0000 |
| commit | 9b8c7c72f59da90cf21af5364cfb34e18188d206 (patch) | |
| tree | 300fe27d09c46cf6410bb81159fdca93f2599c31 /clang/lib/Format | |
| parent | 9f3c12565f7ebd278425ae8ea305c3e3e34ec33a (diff) | |
| download | bcm5719-llvm-9b8c7c72f59da90cf21af5364cfb34e18188d206.tar.gz bcm5719-llvm-9b8c7c72f59da90cf21af5364cfb34e18188d206.zip | |
clang-format: Make sorting includes respect // clang-format off
llvm-svn: 253772
Diffstat (limited to 'clang/lib/Format')
| -rw-r--r-- | clang/lib/Format/Format.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index e7e71c4c7e3..2a7b9acf230 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -1780,11 +1780,20 @@ tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code, for (const auto &Category : Style.IncludeCategories) CategoryRegexs.emplace_back(Category.Regex); + bool FormattingOff = false; + for (;;) { auto Pos = Code.find('\n', SearchFrom); StringRef Line = 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)) { StringRef IncludeName = Matches[2]; unsigned Category; |

