From 86efed9b1b95bb4ba8ca90a4e1a3519af5f4b1e0 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 25 Nov 2013 11:53:05 +0000 Subject: [PATCH] clang-format: Fix formatting of empty files (fixes c-index-tests). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195638 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/Format.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 1f3eef4759..b5b3797f3a 100644 --- a/lib/Format/Format.cpp +++ b/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); } -- 2.40.0