summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/Format.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-05-14 10:31:09 +0000
committerDaniel Jasper <djasper@google.com>2013-05-14 10:31:09 +0000
commitcdd0662b4e5a3f15e97229d43e7c3f5350315e22 (patch)
treee47eac1e8ba5f05c8700cbbe317df101a04e3c0b /clang/lib/Format/Format.cpp
parenteb9af294266ee67924030f546205ea41a3eea0c2 (diff)
downloadbcm5719-llvm-cdd0662b4e5a3f15e97229d43e7c3f5350315e22.tar.gz
bcm5719-llvm-cdd0662b4e5a3f15e97229d43e7c3f5350315e22.zip
Correctly determine ranges for clang-format.
We have been assuming that CharSourceRange::getTokenRange() by itself expands a range until the end of a token, but in fact it only sets IsTokenRange to true. Thus, we have so far only considered the first character of the last token to belong to an unwrapped line. This did not really manifest in symptoms as all edit integrations expand ranges to fully lines. llvm-svn: 181778
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r--clang/lib/Format/Format.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 2bab6e73538..5cb5fef9d54 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1473,9 +1473,9 @@ private:
bool touchesLine(const AnnotatedLine &TheLine) {
const FormatToken *First = &TheLine.First.FormatTok;
const FormatToken *Last = &TheLine.Last->FormatTok;
- CharSourceRange LineRange = CharSourceRange::getTokenRange(
+ CharSourceRange LineRange = CharSourceRange::getCharRange(
First->WhiteSpaceStart.getLocWithOffset(First->LastNewlineOffset),
- Last->Tok.getLocation());
+ Last->Tok.getLocation().getLocWithOffset(Last->TokenLength - 1));
return touchesRanges(LineRange);
}
OpenPOWER on IntegriCloud