summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2013-10-21 08:11:15 +0000
committerManuel Klimek <klimek@google.com>2013-10-21 08:11:15 +0000
commit88033d7a97d2bbf78e16e47975f9ff8ff814a87b (patch)
tree449cbeac2b883622096d69400a5cdda859b22c65 /clang/lib
parent1e995d4f3e4344119cfa9547b2bb37c49ff29266 (diff)
downloadbcm5719-llvm-88033d7a97d2bbf78e16e47975f9ff8ff814a87b.tar.gz
bcm5719-llvm-88033d7a97d2bbf78e16e47975f9ff8ff814a87b.zip
Fixes PR17617: Crash on joining short if statements.
Now that we iterate on the formatting multiple times when we have chains of preprocessor branches, we need to correctly reset the token's previous and next pointer for the first / last token. llvm-svn: 193071
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Format/TokenAnnotator.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.h b/clang/lib/Format/TokenAnnotator.h
index 91f1b4678a1..e51003bac82 100644
--- a/clang/lib/Format/TokenAnnotator.h
+++ b/clang/lib/Format/TokenAnnotator.h
@@ -43,6 +43,11 @@ public:
MustBeDeclaration(Line.MustBeDeclaration), MightBeFunctionDecl(false),
StartsDefinition(false) {
assert(!Line.Tokens.empty());
+
+ // Calculate Next and Previous for all tokens. Note that we must overwrite
+ // Next and Previous for every token, as previous formatting runs might have
+ // left them in a different state.
+ First->Previous = NULL;
FormatToken *Current = First;
for (std::list<UnwrappedLineNode>::const_iterator I = ++Line.Tokens.begin(),
E = Line.Tokens.end();
@@ -60,6 +65,7 @@ public:
}
}
Last = Current;
+ Last->Next = NULL;
}
~AnnotatedLine() {
OpenPOWER on IntegriCloud