r195638 - clang-format: Fix formatting of empty files (fixes c-index-tests).
Daniel Jasper
djasper at google.com
Mon Nov 25 03:53:05 PST 2013
Author: djasper
Date: Mon Nov 25 05:53:05 2013
New Revision: 195638
URL: http://llvm.org/viewvc/llvm-project?rev=195638&view=rev
Log:
clang-format: Fix formatting of empty files (fixes c-index-tests).
Modified:
cfe/trunk/lib/Format/Format.cpp
Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=195638&r1=195637&r2=195638&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon Nov 25 05:53:05 2013
@@ -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);
}
More information about the cfe-commits
mailing list