diff options
| author | Daniel Jasper <djasper@google.com> | 2016-08-30 21:33:41 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2016-08-30 21:33:41 +0000 |
| commit | d6a007803925164fdb40fd4efd647e9d32b2d67b (patch) | |
| tree | 68134461bcf6f2c1145b1dabd67de2287da87362 /clang/lib/Format | |
| parent | befba52f89a70f8cf1b11f57063c7a52fe886188 (diff) | |
| download | bcm5719-llvm-d6a007803925164fdb40fd4efd647e9d32b2d67b.tar.gz bcm5719-llvm-d6a007803925164fdb40fd4efd647e9d32b2d67b.zip | |
clang-format: Correctly calculate affected ranges when sorting #includes.
affectedRanges takes a start and an end offset, not offset and length.
llvm-svn: 280165
Diffstat (limited to 'clang/lib/Format')
| -rw-r--r-- | clang/lib/Format/Format.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index b7d3c55061a..86f4ae1f196 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -1263,10 +1263,10 @@ static void sortCppIncludes(const FormatStyle &Style, ArrayRef<tooling::Range> Ranges, StringRef FileName, tooling::Replacements &Replaces, unsigned *Cursor) { unsigned IncludesBeginOffset = Includes.front().Offset; - unsigned IncludesBlockSize = Includes.back().Offset + - Includes.back().Text.size() - - IncludesBeginOffset; - if (!affectsRange(Ranges, IncludesBeginOffset, IncludesBlockSize)) + unsigned IncludesEndOffset = + Includes.back().Offset + Includes.back().Text.size(); + unsigned IncludesBlockSize = IncludesEndOffset - IncludesBeginOffset; + if (!affectsRange(Ranges, IncludesBeginOffset, IncludesEndOffset)) return; SmallVector<unsigned, 16> Indices; for (unsigned i = 0, e = Includes.size(); i != e; ++i) |

