diff options
author | Daniel Jasper <djasper@google.com> | 2013-10-24 15:23:11 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-10-24 15:23:11 +0000 |
commit | 852bce4ba3c59669a80d4755f07782a3c28c606b (patch) | |
tree | 75b0d599471cc954d85613c12108160f2086d234 /lib/Format/TokenAnnotator.h | |
parent | de2204b56096e2336d19b1feae8b1be99dfb49fa (diff) | |
download | clang-852bce4ba3c59669a80d4755f07782a3c28c606b.tar.gz |
clang-format: Properly reset nested AnnotatedLine structure.
This fixes llvm.org/PR17682.
Without this patch, the following code leads to invalid reads/writes:
DEBUG({
return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
});
#if a
#else
#endif
Because of the #if-#else structure, the code is formatted and annotated
twice and becauce of the nested block, the annotated lines form a
hierarchical structure. This structure was not properly reset between
runs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193352 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/TokenAnnotator.h')
-rw-r--r-- | lib/Format/TokenAnnotator.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/Format/TokenAnnotator.h b/lib/Format/TokenAnnotator.h index e51003bac8..ca8b115415 100644 --- a/lib/Format/TokenAnnotator.h +++ b/lib/Format/TokenAnnotator.h @@ -56,6 +56,7 @@ public: Current->Next = I->Tok; I->Tok->Previous = Current; Current = Current->Next; + Current->Children.clear(); for (SmallVectorImpl<UnwrappedLine>::const_iterator I = Node.Children.begin(), E = Node.Children.end(); |