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 | 472da8644eaaef5911f29f8bff308e2f99c1df81 (patch) | |
tree | 2482492bf14ba86732bdef8a7d3170e3427830dc /clang/lib/Format | |
parent | e865d706782d296b4b546d6970d591569716e4da (diff) | |
download | bcm5719-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')
-rw-r--r-- | clang/lib/Format/TokenAnnotator.h | 1 |
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(); |