summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-11-25 11:53:05 +0000
committerDaniel Jasper <djasper@google.com>2013-11-25 11:53:05 +0000
commit5877bf1b7c63e10df12fbc38a8b57f2df08b9d0b (patch)
tree57213a4fa55a5919d6638a78cb1745822481e0dd
parentccfc0481f17c12a89e797b63e52b681b87527d97 (diff)
downloadbcm5719-llvm-5877bf1b7c63e10df12fbc38a8b57f2df08b9d0b.tar.gz
bcm5719-llvm-5877bf1b7c63e10df12fbc38a8b57f2df08b9d0b.zip
clang-format: Fix formatting of empty files (fixes c-index-tests).
llvm-svn: 195638
-rw-r--r--clang/lib/Format/Format.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 1f3eef47590..b5b3797f3a0 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1332,8 +1332,9 @@ private:
SourceLocation Start = First.WhitespaceRange.getBegin();
if (!IncludeLeadingNewlines)
Start = Start.getLocWithOffset(First.LastNewlineOffset);
- SourceLocation End = Last.getStartOfNonWhitespace().getLocWithOffset(
- Last.TokenText.size() - 1);
+ SourceLocation End = Last.getStartOfNonWhitespace();
+ if (Last.TokenText.size() > 0)
+ End = End.getLocWithOffset(Last.TokenText.size() - 1);
CharSourceRange Range = CharSourceRange::getCharRange(Start, End);
return affectsCharSourceRange(Range);
}
OpenPOWER on IntegriCloud