summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/Format.cpp
diff options
context:
space:
mode:
authorEric Liu <ioeric@google.com>2016-12-09 11:45:50 +0000
committerEric Liu <ioeric@google.com>2016-12-09 11:45:50 +0000
commit21d10328551893fc67d21501300e71573d085e26 (patch)
treedd0796ee48b9465269cffa0b233e05592ad572ad /clang/lib/Format/Format.cpp
parent6bd372bae7b71defe5944c05ef9ca6c29f43df19 (diff)
downloadbcm5719-llvm-21d10328551893fc67d21501300e71573d085e26.tar.gz
bcm5719-llvm-21d10328551893fc67d21501300e71573d085e26.zip
[clang-format] calculate MaxInsertOffset in the original code correctly.
Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D27615 llvm-svn: 289203
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r--clang/lib/Format/Format.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 4b24b0b7336..bcea5ac411a 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1677,7 +1677,9 @@ fixCppIncludeInsertions(StringRef Code, const tooling::Replacements &Replaces,
unsigned MinInsertOffset =
getOffsetAfterHeaderGuardsAndComments(FileName, Code, Style);
StringRef TrimmedCode = Code.drop_front(MinInsertOffset);
+ // Max insertion offset in the original code.
unsigned MaxInsertOffset =
+ MinInsertOffset +
getMaxHeaderInsertionOffset(FileName, TrimmedCode, Style);
SmallVector<StringRef, 32> Lines;
TrimmedCode.split(Lines, '\n');
OpenPOWER on IntegriCloud