]> granicus.if.org Git - clang/commitdiff
Fix uninitialized access error found by valgrind.
authorManuel Klimek <klimek@google.com>
Wed, 22 May 2013 14:01:08 +0000 (14:01 +0000)
committerManuel Klimek <klimek@google.com>
Wed, 22 May 2013 14:01:08 +0000 (14:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182476 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/WhitespaceManager.cpp

index d4953b4a784c09ee6aaae04f428fc6ecfec1039d..d1a925c5160ae217e43215ae0dee2c205ca39153 100644 (file)
@@ -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;
 }