summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.h
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-10-24 15:23:11 +0000
committerDaniel Jasper <djasper@google.com>2013-10-24 15:23:11 +0000
commit472da8644eaaef5911f29f8bff308e2f99c1df81 (patch)
tree2482492bf14ba86732bdef8a7d3170e3427830dc /clang/lib/Format/TokenAnnotator.h
parente865d706782d296b4b546d6970d591569716e4da (diff)
downloadbcm5719-llvm-472da8644eaaef5911f29f8bff308e2f99c1df81.tar.gz
bcm5719-llvm-472da8644eaaef5911f29f8bff308e2f99c1df81.zip
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. llvm-svn: 193352
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.h')
-rw-r--r--clang/lib/Format/TokenAnnotator.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.h b/clang/lib/Format/TokenAnnotator.h
index e51003bac82..ca8b1154157 100644
--- a/clang/lib/Format/TokenAnnotator.h
+++ b/clang/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();
OpenPOWER on IntegriCloud