From 60d524915388177397924474499a7117576fefc8 Mon Sep 17 00:00:00 2001 From: Jacques Pienaar Date: Tue, 24 Feb 2015 23:23:24 +0000 Subject: [PATCH] clang-format: Change location of stashed token Commit of patch in http://reviews.llvm.org/D7871 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230395 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/Format.cpp | 6 ++++-- unittests/Format/FormatTest.cpp | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index f3f362bb4b..035dc735d9 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -940,11 +940,13 @@ private: FormatTok = new (Allocator.Allocate()) FormatToken; FormatTok->Tok = Tok; SourceLocation TokLocation = - FormatTok->Tok.getLocation().getLocWithOffset(1); + FormatTok->Tok.getLocation().getLocWithOffset(Tok.getLength() - 1); + FormatTok->Tok.setLocation(TokLocation); FormatTok->WhitespaceRange = SourceRange(TokLocation, TokLocation); FormatTok->TokenText = TokenText; FormatTok->ColumnWidth = 1; - FormatTok->OriginalColumn = OriginalColumn; + FormatTok->OriginalColumn = OriginalColumn + 1; + return FormatTok; } diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 072c8afe63..999b8f3acd 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -9753,6 +9753,7 @@ TEST_F(FormatTest, TripleAngleBrackets) { TEST_F(FormatTest, MergeLessLessAtEnd) { verifyFormat("<<"); + EXPECT_EQ("< < <", format("\\\n<<<")); verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaallvm::outs() <<"); verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -- 2.40.0