summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.h
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.h')
-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