From 5877bf1b7c63e10df12fbc38a8b57f2df08b9d0b Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 25 Nov 2013 11:53:05 +0000 Subject: clang-format: Fix formatting of empty files (fixes c-index-tests). llvm-svn: 195638 --- clang/lib/Format/Format.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'clang') 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); } -- cgit v1.2.3