From 0cd57b52c932c89fae03f0001add4821deaff5e7 Mon Sep 17 00:00:00 2001 From: Manuel Klimek Date: Wed, 22 May 2013 14:01:08 +0000 Subject: [PATCH] Fix uninitialized access error found by valgrind. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182476 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/WhitespaceManager.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Format/WhitespaceManager.cpp b/lib/Format/WhitespaceManager.cpp index d4953b4a78..d1a925c516 100644 --- a/lib/Format/WhitespaceManager.cpp +++ b/lib/Format/WhitespaceManager.cpp @@ -129,6 +129,9 @@ void WhitespaceManager::calculateLineBreakInformation() { (Changes[i].NewlinesBefore > 0 || Changes[i].Kind == tok::eof) && Changes[i - 1].Kind == tok::comment; } + // FIXME: The last token is currently not always an eof token; in those + // cases, setting TokenLength of the last token to 0 is wrong. + Changes.back().TokenLength = 0; Changes.back().IsTrailingComment = Changes.back().Kind == tok::comment; } -- 2.50.1