blob: ff1f1aa8534f31c60a7ac025d73758a46f6b6791 [file] [log] [blame]
Daniel Jasper6b2afe42013-08-16 11:20:30 +00001//===--- ContinuationIndenter.cpp - Format C++ code -----------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9///
10/// \file
11/// \brief This file implements the continuation indenter.
12///
13//===----------------------------------------------------------------------===//
14
15#define DEBUG_TYPE "format-formatter"
16
17#include "BreakableToken.h"
18#include "ContinuationIndenter.h"
19#include "WhitespaceManager.h"
20#include "clang/Basic/OperatorPrecedence.h"
21#include "clang/Basic/SourceManager.h"
22#include "clang/Format/Format.h"
23#include "llvm/Support/Debug.h"
24#include <string>
25
26namespace clang {
27namespace format {
28
29// Returns the length of everything up to the first possible line break after
30// the ), ], } or > matching \c Tok.
31static unsigned getLengthToMatchingParen(const FormatToken &Tok) {
32 if (Tok.MatchingParen == NULL)
33 return 0;
34 FormatToken *End = Tok.MatchingParen;
35 while (End->Next && !End->Next->CanBreakBefore) {
36 End = End->Next;
37 }
38 return End->TotalLength - Tok.TotalLength + 1;
39}
40
Daniel Jasperd3fef0f2013-08-27 14:24:43 +000041// Returns \c true if \c Tok is the "." or "->" of a call and starts the next
42// segment of a builder type call.
43static bool startsSegmentOfBuilderTypeCall(const FormatToken &Tok) {
44 return Tok.isMemberAccess() && Tok.Previous && Tok.Previous->closesScope();
45}
46
Daniel Jasper19ccb122013-10-08 05:11:18 +000047// Returns \c true if \c Current starts a new parameter.
48static bool startsNextParameter(const FormatToken &Current,
49 const FormatStyle &Style) {
50 const FormatToken &Previous = *Current.Previous;
51 if (Current.Type == TT_CtorInitializerComma &&
52 Style.BreakConstructorInitializersBeforeComma)
53 return true;
54 return Previous.is(tok::comma) && !Current.isTrailingComment() &&
55 (Previous.Type != TT_CtorInitializerComma ||
56 !Style.BreakConstructorInitializersBeforeComma);
57}
58
Daniel Jasper6b2afe42013-08-16 11:20:30 +000059ContinuationIndenter::ContinuationIndenter(const FormatStyle &Style,
60 SourceManager &SourceMgr,
Daniel Jasper6b2afe42013-08-16 11:20:30 +000061 WhitespaceManager &Whitespaces,
62 encoding::Encoding Encoding,
63 bool BinPackInconclusiveFunctions)
Daniel Jasper567dcf92013-09-05 09:29:45 +000064 : Style(Style), SourceMgr(SourceMgr), Whitespaces(Whitespaces),
65 Encoding(Encoding),
Daniel Jasper6b2afe42013-08-16 11:20:30 +000066 BinPackInconclusiveFunctions(BinPackInconclusiveFunctions) {}
67
Daniel Jasper567dcf92013-09-05 09:29:45 +000068LineState ContinuationIndenter::getInitialState(unsigned FirstIndent,
Daniel Jasperb77d7412013-09-06 07:54:20 +000069 const AnnotatedLine *Line,
70 bool DryRun) {
Daniel Jasper6b2afe42013-08-16 11:20:30 +000071 LineState State;
Daniel Jasper567dcf92013-09-05 09:29:45 +000072 State.FirstIndent = FirstIndent;
Daniel Jasper6b2afe42013-08-16 11:20:30 +000073 State.Column = FirstIndent;
Daniel Jasper567dcf92013-09-05 09:29:45 +000074 State.Line = Line;
75 State.NextToken = Line->First;
Daniel Jasper6b2afe42013-08-16 11:20:30 +000076 State.Stack.push_back(ParenState(FirstIndent, FirstIndent,
77 /*AvoidBinPacking=*/false,
78 /*NoLineBreak=*/false));
79 State.LineContainsContinuedForLoopSection = false;
80 State.ParenLevel = 0;
81 State.StartOfStringLiteral = 0;
82 State.StartOfLineLevel = State.ParenLevel;
83 State.LowestLevelOnLine = State.ParenLevel;
84 State.IgnoreStackForComparison = false;
85
86 // The first token has already been indented and thus consumed.
Daniel Jasperb77d7412013-09-06 07:54:20 +000087 moveStateToNextToken(State, DryRun, /*Newline=*/false);
Daniel Jasper6b2afe42013-08-16 11:20:30 +000088 return State;
89}
90
91bool ContinuationIndenter::canBreak(const LineState &State) {
92 const FormatToken &Current = *State.NextToken;
93 const FormatToken &Previous = *Current.Previous;
94 assert(&Previous == Current.Previous);
95 if (!Current.CanBreakBefore &&
96 !(Current.is(tok::r_brace) && State.Stack.back().BreakBeforeClosingBrace))
97 return false;
98 // The opening "{" of a braced list has to be on the same line as the first
99 // element if it is nested in another braced init list or function call.
100 if (!Current.MustBreakBefore && Previous.is(tok::l_brace) &&
Daniel Jasper567dcf92013-09-05 09:29:45 +0000101 Previous.BlockKind == BK_BracedInit && Previous.Previous &&
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000102 Previous.Previous->isOneOf(tok::l_brace, tok::l_paren, tok::comma))
103 return false;
104 // This prevents breaks like:
105 // ...
106 // SomeParameter, OtherParameter).DoSomething(
107 // ...
108 // As they hide "DoSomething" and are generally bad for readability.
109 if (Previous.opensScope() && State.LowestLevelOnLine < State.StartOfLineLevel)
110 return false;
Daniel Jasperd3fef0f2013-08-27 14:24:43 +0000111 if (Current.isMemberAccess() && State.Stack.back().ContainsUnwrappedBuilder)
112 return false;
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000113 return !State.Stack.back().NoLineBreak;
114}
115
116bool ContinuationIndenter::mustBreak(const LineState &State) {
117 const FormatToken &Current = *State.NextToken;
118 const FormatToken &Previous = *Current.Previous;
119 if (Current.MustBreakBefore || Current.Type == TT_InlineASMColon)
120 return true;
Daniel Jasper57981202013-09-13 09:20:45 +0000121 if ((!Style.Cpp11BracedListStyle ||
122 (Current.MatchingParen &&
123 Current.MatchingParen->BlockKind == BK_Block)) &&
124 Current.is(tok::r_brace) && State.Stack.back().BreakBeforeClosingBrace)
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000125 return true;
126 if (Previous.is(tok::semi) && State.LineContainsContinuedForLoopSection)
127 return true;
Daniel Jasper19ccb122013-10-08 05:11:18 +0000128 if ((startsNextParameter(Current, Style) || Previous.is(tok::semi) ||
129 Current.is(tok::question) ||
130 (Current.Type == TT_ConditionalExpr && Previous.isNot(tok::question))) &&
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000131 State.Stack.back().BreakBeforeParameter && !Current.isTrailingComment() &&
132 !Current.isOneOf(tok::r_paren, tok::r_brace))
133 return true;
134 if (Style.AlwaysBreakBeforeMultilineStrings &&
Daniel Jasper4df1ff92013-08-23 11:57:34 +0000135 State.Column > State.Stack.back().Indent && // Breaking saves columns.
136 Previous.isNot(tok::lessless) && Previous.Type != TT_InlineASMColon &&
137 NextIsMultilineString(State))
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000138 return true;
139
140 if (!Style.BreakBeforeBinaryOperators) {
141 // If we need to break somewhere inside the LHS of a binary expression, we
142 // should also break after the operator. Otherwise, the formatting would
143 // hide the operator precedence, e.g. in:
144 // if (aaaaaaaaaaaaaa ==
145 // bbbbbbbbbbbbbb && c) {..
146 // For comparisons, we only apply this rule, if the LHS is a binary
147 // expression itself as otherwise, the line breaks seem superfluous.
148 // We need special cases for ">>" which we have split into two ">" while
149 // lexing in order to make template parsing easier.
150 //
151 // FIXME: We'll need something similar for styles that break before binary
152 // operators.
153 bool IsComparison = (Previous.getPrecedence() == prec::Relational ||
154 Previous.getPrecedence() == prec::Equality) &&
155 Previous.Previous &&
156 Previous.Previous->Type != TT_BinaryOperator; // For >>.
157 bool LHSIsBinaryExpr =
Daniel Jasperdb4813a2013-09-06 08:08:14 +0000158 Previous.Previous && Previous.Previous->EndsBinaryExpression;
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000159 if (Previous.Type == TT_BinaryOperator &&
160 (!IsComparison || LHSIsBinaryExpr) &&
161 Current.Type != TT_BinaryOperator && // For >>.
162 !Current.isTrailingComment() &&
163 !Previous.isOneOf(tok::lessless, tok::question) &&
164 Previous.getPrecedence() != prec::Assignment &&
165 State.Stack.back().BreakBeforeParameter)
166 return true;
167 }
168
169 // Same as above, but for the first "<<" operator.
170 if (Current.is(tok::lessless) && State.Stack.back().BreakBeforeParameter &&
171 State.Stack.back().FirstLessLess == 0)
172 return true;
173
174 // FIXME: Comparing LongestObjCSelectorName to 0 is a hacky way of finding
175 // out whether it is the first parameter. Clean this up.
176 if (Current.Type == TT_ObjCSelectorName &&
177 Current.LongestObjCSelectorName == 0 &&
178 State.Stack.back().BreakBeforeParameter)
179 return true;
180 if ((Current.Type == TT_CtorInitializerColon ||
181 (Previous.ClosesTemplateDeclaration && State.ParenLevel == 0)))
182 return true;
183
184 if ((Current.Type == TT_StartOfName || Current.is(tok::kw_operator)) &&
Daniel Jasper567dcf92013-09-05 09:29:45 +0000185 State.Line->MightBeFunctionDecl &&
186 State.Stack.back().BreakBeforeParameter && State.ParenLevel == 0)
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000187 return true;
Daniel Jasperd3fef0f2013-08-27 14:24:43 +0000188 if (startsSegmentOfBuilderTypeCall(Current) &&
Daniel Jaspereb331832013-08-30 07:12:40 +0000189 (State.Stack.back().CallContinuation != 0 ||
190 (State.Stack.back().BreakBeforeParameter &&
191 State.Stack.back().ContainsUnwrappedBuilder)))
Daniel Jasperd3fef0f2013-08-27 14:24:43 +0000192 return true;
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000193 return false;
194}
195
196unsigned ContinuationIndenter::addTokenToState(LineState &State, bool Newline,
Daniel Jasperd4a03db2013-08-22 15:00:41 +0000197 bool DryRun,
198 unsigned ExtraSpaces) {
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000199 const FormatToken &Current = *State.NextToken;
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000200
201 if (State.Stack.size() == 0 || Current.Type == TT_ImplicitStringLiteral) {
202 // FIXME: Is this correct?
203 int WhitespaceLength = SourceMgr.getSpellingColumnNumber(
204 State.NextToken->WhitespaceRange.getEnd()) -
205 SourceMgr.getSpellingColumnNumber(
206 State.NextToken->WhitespaceRange.getBegin());
Alexander Kornienko83a7dcd2013-09-10 09:38:25 +0000207 State.Column += WhitespaceLength + State.NextToken->ColumnWidth;
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000208 State.NextToken = State.NextToken->Next;
209 return 0;
210 }
211
Alexander Kornienkoe5321c42013-10-01 14:41:18 +0000212 unsigned Penalty = 0;
213 if (Newline)
214 Penalty = addTokenOnNewLine(State, DryRun);
215 else
216 addTokenOnCurrentLine(State, DryRun, ExtraSpaces);
217
218 return moveStateToNextToken(State, DryRun, Newline) + Penalty;
219}
220
221void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
222 unsigned ExtraSpaces) {
223 const FormatToken &Current = *State.NextToken;
224 const FormatToken &Previous = *State.NextToken->Previous;
225 if (Current.is(tok::equal) &&
226 (State.Line->First->is(tok::kw_for) || State.ParenLevel == 0) &&
227 State.Stack.back().VariablePos == 0) {
228 State.Stack.back().VariablePos = State.Column;
229 // Move over * and & if they are bound to the variable name.
230 const FormatToken *Tok = &Previous;
231 while (Tok && State.Stack.back().VariablePos >= Tok->ColumnWidth) {
232 State.Stack.back().VariablePos -= Tok->ColumnWidth;
233 if (Tok->SpacesRequiredBefore != 0)
234 break;
235 Tok = Tok->Previous;
236 }
237 if (Previous.PartOfMultiVariableDeclStmt)
238 State.Stack.back().LastSpace = State.Stack.back().VariablePos;
239 }
240
241 unsigned Spaces = Current.SpacesRequiredBefore + ExtraSpaces;
242
243 if (!DryRun)
244 Whitespaces.replaceWhitespace(Current, /*Newlines=*/0, /*IndentLevel=*/0,
245 Spaces, State.Column + Spaces);
246
247 if (Current.Type == TT_ObjCSelectorName && State.Stack.back().ColonPos == 0) {
248 if (State.Stack.back().Indent + Current.LongestObjCSelectorName >
249 State.Column + Spaces + Current.ColumnWidth)
250 State.Stack.back().ColonPos =
251 State.Stack.back().Indent + Current.LongestObjCSelectorName;
252 else
253 State.Stack.back().ColonPos = State.Column + Spaces + Current.ColumnWidth;
254 }
255
256 if (Previous.opensScope() && Previous.Type != TT_ObjCMethodExpr &&
257 Current.Type != TT_LineComment)
258 State.Stack.back().Indent = State.Column + Spaces;
Daniel Jasper19ccb122013-10-08 05:11:18 +0000259 if (State.Stack.back().AvoidBinPacking && startsNextParameter(Current, Style))
Alexander Kornienkoe5321c42013-10-01 14:41:18 +0000260 State.Stack.back().NoLineBreak = true;
261 if (startsSegmentOfBuilderTypeCall(Current))
262 State.Stack.back().ContainsUnwrappedBuilder = true;
263
264 State.Column += Spaces;
265 if (Current.is(tok::l_paren) && Previous.isOneOf(tok::kw_if, tok::kw_for))
266 // Treat the condition inside an if as if it was a second function
267 // parameter, i.e. let nested calls have an indent of 4.
268 State.Stack.back().LastSpace = State.Column + 1; // 1 is length of "(".
269 else if (Previous.is(tok::comma))
270 State.Stack.back().LastSpace = State.Column;
271 else if ((Previous.Type == TT_BinaryOperator ||
272 Previous.Type == TT_ConditionalExpr ||
273 Previous.Type == TT_UnaryOperator ||
274 Previous.Type == TT_CtorInitializerColon) &&
275 (Previous.getPrecedence() != prec::Assignment ||
276 Current.StartsBinaryExpression))
277 // Always indent relative to the RHS of the expression unless this is a
278 // simple assignment without binary expression on the RHS. Also indent
279 // relative to unary operators and the colons of constructor initializers.
280 State.Stack.back().LastSpace = State.Column;
281 else if (Previous.Type == TT_InheritanceColon)
282 State.Stack.back().Indent = State.Column;
283 else if (Previous.opensScope()) {
284 // If a function has a trailing call, indent all parameters from the
285 // opening parenthesis. This avoids confusing indents like:
286 // OuterFunction(InnerFunctionCall( // break
287 // ParameterToInnerFunction)) // break
288 // .SecondInnerFunctionCall();
289 bool HasTrailingCall = false;
290 if (Previous.MatchingParen) {
291 const FormatToken *Next = Previous.MatchingParen->getNextNonComment();
292 HasTrailingCall = Next && Next->isMemberAccess();
293 }
294 if (HasTrailingCall &&
295 State.Stack[State.Stack.size() - 2].CallContinuation == 0)
296 State.Stack.back().LastSpace = State.Column;
297 }
298}
299
300unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State,
301 bool DryRun) {
302 const FormatToken &Current = *State.NextToken;
303 const FormatToken &Previous = *State.NextToken->Previous;
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000304 // If we are continuing an expression, we want to indent an extra 4 spaces.
305 unsigned ContinuationIndent =
306 std::max(State.Stack.back().LastSpace, State.Stack.back().Indent) + 4;
Alexander Kornienkoe5321c42013-10-01 14:41:18 +0000307 // Extra penalty that needs to be added because of the way certain line
308 // breaks are chosen.
309 unsigned Penalty = 0;
Daniel Jasperd4a03db2013-08-22 15:00:41 +0000310
Alexander Kornienkoe5321c42013-10-01 14:41:18 +0000311 const FormatToken *PreviousNonComment =
312 State.NextToken->getPreviousNonComment();
313 // The first line break on any ParenLevel causes an extra penalty in order
314 // prefer similar line breaks.
315 if (!State.Stack.back().ContainsLineBreak)
316 Penalty += 15;
317 State.Stack.back().ContainsLineBreak = true;
Daniel Jasperd4a03db2013-08-22 15:00:41 +0000318
Alexander Kornienkoe5321c42013-10-01 14:41:18 +0000319 Penalty += State.NextToken->SplitPenalty;
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000320
Alexander Kornienkoe5321c42013-10-01 14:41:18 +0000321 // Breaking before the first "<<" is generally not desirable if the LHS is
322 // short.
323 if (Current.is(tok::lessless) && State.Stack.back().FirstLessLess == 0 &&
324 State.Column <= Style.ColumnLimit / 2)
325 Penalty += Style.PenaltyBreakFirstLessLess;
326
327 if (Current.is(tok::l_brace) && Current.BlockKind == BK_Block) {
328 State.Column = State.FirstIndent;
329 } else if (Current.is(tok::r_brace)) {
330 if (Current.MatchingParen &&
331 (Current.MatchingParen->BlockKind == BK_BracedInit ||
332 !Current.MatchingParen->Children.empty()))
333 State.Column = State.Stack[State.Stack.size() - 2].LastSpace;
334 else
Daniel Jasper57981202013-09-13 09:20:45 +0000335 State.Column = State.FirstIndent;
Alexander Kornienkoe5321c42013-10-01 14:41:18 +0000336 } else if (Current.is(tok::string_literal) &&
337 State.StartOfStringLiteral != 0) {
338 State.Column = State.StartOfStringLiteral;
339 State.Stack.back().BreakBeforeParameter = true;
340 } else if (Current.is(tok::lessless) &&
341 State.Stack.back().FirstLessLess != 0) {
342 State.Column = State.Stack.back().FirstLessLess;
343 } else if (Current.isMemberAccess()) {
344 if (State.Stack.back().CallContinuation == 0) {
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000345 State.Column = ContinuationIndent;
Alexander Kornienkoe5321c42013-10-01 14:41:18 +0000346 State.Stack.back().CallContinuation = State.Column;
347 } else {
348 State.Column = State.Stack.back().CallContinuation;
349 }
350 } else if (Current.Type == TT_ConditionalExpr) {
351 State.Column = State.Stack.back().QuestionColumn;
352 } else if (Previous.is(tok::comma) && State.Stack.back().VariablePos != 0) {
353 State.Column = State.Stack.back().VariablePos;
354 } else if ((PreviousNonComment &&
355 PreviousNonComment->ClosesTemplateDeclaration) ||
356 ((Current.Type == TT_StartOfName ||
357 Current.is(tok::kw_operator)) &&
358 State.ParenLevel == 0 &&
359 (!Style.IndentFunctionDeclarationAfterType ||
360 State.Line->StartsDefinition))) {
361 State.Column = State.Stack.back().Indent;
362 } else if (Current.Type == TT_ObjCSelectorName) {
363 if (State.Stack.back().ColonPos > Current.ColumnWidth) {
364 State.Column = State.Stack.back().ColonPos - Current.ColumnWidth;
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000365 } else {
366 State.Column = State.Stack.back().Indent;
Alexander Kornienkoe5321c42013-10-01 14:41:18 +0000367 State.Stack.back().ColonPos = State.Column + Current.ColumnWidth;
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000368 }
Alexander Kornienkoe5321c42013-10-01 14:41:18 +0000369 } else if (Current.is(tok::l_square) && Current.Type != TT_ObjCMethodExpr &&
370 Current.Type != TT_LambdaLSquare) {
371 if (State.Stack.back().StartOfArraySubscripts != 0)
372 State.Column = State.Stack.back().StartOfArraySubscripts;
373 else
374 State.Column = ContinuationIndent;
375 } else if (Current.Type == TT_StartOfName ||
376 Previous.isOneOf(tok::coloncolon, tok::equal) ||
377 Previous.Type == TT_ObjCMethodExpr) {
378 State.Column = ContinuationIndent;
379 } else if (Current.Type == TT_CtorInitializerColon) {
380 State.Column = State.FirstIndent + Style.ConstructorInitializerIndentWidth;
381 } else if (Current.Type == TT_CtorInitializerComma) {
382 State.Column = State.Stack.back().Indent;
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000383 } else {
Alexander Kornienkoe5321c42013-10-01 14:41:18 +0000384 State.Column = State.Stack.back().Indent;
385 // Ensure that we fall back to indenting 4 spaces instead of just
386 // flushing continuations left.
387 if (State.Column == State.FirstIndent)
388 State.Column += 4;
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000389 }
390
Alexander Kornienkoe5321c42013-10-01 14:41:18 +0000391 if (Current.is(tok::question))
392 State.Stack.back().BreakBeforeParameter = true;
393 if ((Previous.isOneOf(tok::comma, tok::semi) &&
394 !State.Stack.back().AvoidBinPacking) ||
395 Previous.Type == TT_BinaryOperator)
396 State.Stack.back().BreakBeforeParameter = false;
397 if (Previous.Type == TT_TemplateCloser && State.ParenLevel == 0)
398 State.Stack.back().BreakBeforeParameter = false;
399
400 if (!DryRun) {
401 unsigned Newlines = 1;
402 if (Current.is(tok::comment))
403 Newlines = std::max(Newlines, std::min(Current.NewlinesBefore,
404 Style.MaxEmptyLinesToKeep + 1));
405 Whitespaces.replaceWhitespace(Current, Newlines, State.Line->Level,
406 State.Column, State.Column,
407 State.Line->InPPDirective);
408 }
409
410 if (!Current.isTrailingComment())
411 State.Stack.back().LastSpace = State.Column;
412 if (Current.isMemberAccess())
413 State.Stack.back().LastSpace += Current.ColumnWidth;
414 State.StartOfLineLevel = State.ParenLevel;
415 State.LowestLevelOnLine = State.ParenLevel;
416
417 // Any break on this level means that the parent level has been broken
418 // and we need to avoid bin packing there.
419 for (unsigned i = 0, e = State.Stack.size() - 1; i != e; ++i) {
420 State.Stack[i].BreakBeforeParameter = true;
421 }
422 const FormatToken *TokenBefore = Current.getPreviousNonComment();
423 if (TokenBefore && !TokenBefore->isOneOf(tok::comma, tok::semi) &&
424 TokenBefore->Type != TT_TemplateCloser &&
425 TokenBefore->Type != TT_BinaryOperator && !TokenBefore->opensScope())
426 State.Stack.back().BreakBeforeParameter = true;
427
428 // If we break after {, we should also break before the corresponding }.
429 if (Previous.is(tok::l_brace))
430 State.Stack.back().BreakBeforeClosingBrace = true;
431
432 if (State.Stack.back().AvoidBinPacking) {
433 // If we are breaking after '(', '{', '<', this is not bin packing
434 // unless AllowAllParametersOfDeclarationOnNextLine is false.
435 if (!(Previous.isOneOf(tok::l_paren, tok::l_brace) ||
436 Previous.Type == TT_BinaryOperator) ||
437 (!Style.AllowAllParametersOfDeclarationOnNextLine &&
438 State.Line->MustBeDeclaration))
439 State.Stack.back().BreakBeforeParameter = true;
440 }
441
442 return Penalty;
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000443}
444
445unsigned ContinuationIndenter::moveStateToNextToken(LineState &State,
446 bool DryRun, bool Newline) {
447 const FormatToken &Current = *State.NextToken;
448 assert(State.Stack.size());
449
450 if (Current.Type == TT_InheritanceColon)
451 State.Stack.back().AvoidBinPacking = true;
452 if (Current.is(tok::lessless) && State.Stack.back().FirstLessLess == 0)
453 State.Stack.back().FirstLessLess = State.Column;
Daniel Jasper567dcf92013-09-05 09:29:45 +0000454 if (Current.is(tok::l_square) && Current.Type != TT_LambdaLSquare &&
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000455 State.Stack.back().StartOfArraySubscripts == 0)
456 State.Stack.back().StartOfArraySubscripts = State.Column;
457 if (Current.is(tok::question))
458 State.Stack.back().QuestionColumn = State.Column;
459 if (!Current.opensScope() && !Current.closesScope())
460 State.LowestLevelOnLine =
461 std::min(State.LowestLevelOnLine, State.ParenLevel);
Daniel Jasperd3fef0f2013-08-27 14:24:43 +0000462 if (Current.isMemberAccess())
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000463 State.Stack.back().StartOfFunctionCall =
Alexander Kornienko83a7dcd2013-09-10 09:38:25 +0000464 Current.LastInChainOfCalls ? 0 : State.Column + Current.ColumnWidth;
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000465 if (Current.Type == TT_CtorInitializerColon) {
466 // Indent 2 from the column, so:
467 // SomeClass::SomeClass()
468 // : First(...), ...
469 // Next(...)
470 // ^ line up here.
471 State.Stack.back().Indent =
472 State.Column + (Style.BreakConstructorInitializersBeforeComma ? 0 : 2);
473 if (Style.ConstructorInitializerAllOnOneLineOrOnePerLine)
474 State.Stack.back().AvoidBinPacking = true;
475 State.Stack.back().BreakBeforeParameter = false;
476 }
477
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000478 // In ObjC method declaration we align on the ":" of parameters, but we need
479 // to ensure that we indent parameters on subsequent lines by at least 4.
480 if (Current.Type == TT_ObjCMethodSpecifier)
481 State.Stack.back().Indent += 4;
482
483 // Insert scopes created by fake parenthesis.
484 const FormatToken *Previous = Current.getPreviousNonComment();
485 // Don't add extra indentation for the first fake parenthesis after
486 // 'return', assignements or opening <({[. The indentation for these cases
487 // is special cased.
488 bool SkipFirstExtraIndent =
Daniel Jasperf78bf4a2013-09-30 08:29:03 +0000489 (Previous && (Previous->opensScope() || Previous->is(tok::kw_return) ||
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000490 Previous->getPrecedence() == prec::Assignment));
491 for (SmallVectorImpl<prec::Level>::const_reverse_iterator
492 I = Current.FakeLParens.rbegin(),
493 E = Current.FakeLParens.rend();
494 I != E; ++I) {
495 ParenState NewParenState = State.Stack.back();
496 NewParenState.ContainsLineBreak = false;
Daniel Jasperf78bf4a2013-09-30 08:29:03 +0000497
498 // Indent from 'LastSpace' unless this the fake parentheses encapsulating a
499 // builder type call after 'return'. If such a call is line-wrapped, we
500 // commonly just want to indent from the start of the line.
501 if (!Previous || Previous->isNot(tok::kw_return) || *I > 0)
502 NewParenState.Indent =
503 std::max(std::max(State.Column, NewParenState.Indent),
504 State.Stack.back().LastSpace);
505
Daniel Jasper567dcf92013-09-05 09:29:45 +0000506 // Do not indent relative to the fake parentheses inserted for "." or "->".
507 // This is a special case to make the following to statements consistent:
508 // OuterFunction(InnerFunctionCall( // break
509 // ParameterToInnerFunction));
510 // OuterFunction(SomeObject.InnerFunctionCall( // break
511 // ParameterToInnerFunction));
512 if (*I > prec::Unknown)
513 NewParenState.LastSpace = std::max(NewParenState.LastSpace, State.Column);
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000514
515 // Always indent conditional expressions. Never indent expression where
516 // the 'operator' is ',', ';' or an assignment (i.e. *I <=
517 // prec::Assignment) as those have different indentation rules. Indent
518 // other expression, unless the indentation needs to be skipped.
519 if (*I == prec::Conditional ||
520 (!SkipFirstExtraIndent && *I > prec::Assignment &&
521 !Style.BreakBeforeBinaryOperators))
522 NewParenState.Indent += 4;
523 if (Previous && !Previous->opensScope())
524 NewParenState.BreakBeforeParameter = false;
525 State.Stack.push_back(NewParenState);
526 SkipFirstExtraIndent = false;
527 }
528
529 // If we encounter an opening (, [, { or <, we add a level to our stacks to
530 // prepare for the following tokens.
531 if (Current.opensScope()) {
532 unsigned NewIndent;
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000533 bool AvoidBinPacking;
534 if (Current.is(tok::l_brace)) {
Daniel Jasper567dcf92013-09-05 09:29:45 +0000535 if (Current.MatchingParen && Current.BlockKind == BK_Block) {
Daniel Jasper1a925bc2013-09-05 10:48:50 +0000536 // If this is an l_brace starting a nested block, we pretend (wrt. to
537 // indentation) that we already consumed the corresponding r_brace.
538 // Thus, we remove all ParenStates caused bake fake parentheses that end
539 // at the r_brace. The net effect of this is that we don't indent
540 // relative to the l_brace, if the nested block is the last parameter of
541 // a function. For example, this formats:
542 //
543 // SomeFunction(a, [] {
544 // f(); // break
545 // });
546 //
547 // instead of:
548 // SomeFunction(a, [] {
549 // f(); // break
550 // });
Daniel Jasper567dcf92013-09-05 09:29:45 +0000551 for (unsigned i = 0; i != Current.MatchingParen->FakeRParens; ++i)
552 State.Stack.pop_back();
Daniel Jasper57981202013-09-13 09:20:45 +0000553 NewIndent = State.Stack.back().LastSpace + Style.IndentWidth;
Daniel Jasper567dcf92013-09-05 09:29:45 +0000554 } else {
555 NewIndent = State.Stack.back().LastSpace +
556 (Style.Cpp11BracedListStyle ? 4 : Style.IndentWidth);
557 }
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000558 const FormatToken *NextNoComment = Current.getNextNonComment();
Daniel Jasper57981202013-09-13 09:20:45 +0000559 AvoidBinPacking = Current.BlockKind == BK_Block ||
560 (NextNoComment &&
561 NextNoComment->Type == TT_DesignatedInitializerPeriod);
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000562 } else {
Daniel Jasper567dcf92013-09-05 09:29:45 +0000563 NewIndent = 4 + std::max(State.Stack.back().LastSpace,
564 State.Stack.back().StartOfFunctionCall);
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000565 AvoidBinPacking = !Style.BinPackParameters ||
566 (Style.ExperimentalAutoDetectBinPacking &&
567 (Current.PackingKind == PPK_OnePerLine ||
568 (!BinPackInconclusiveFunctions &&
569 Current.PackingKind == PPK_Inconclusive)));
570 }
571
Daniel Jasper567dcf92013-09-05 09:29:45 +0000572 State.Stack.push_back(ParenState(NewIndent, State.Stack.back().LastSpace,
573 AvoidBinPacking,
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000574 State.Stack.back().NoLineBreak));
Daniel Jasper57981202013-09-13 09:20:45 +0000575 State.Stack.back().BreakBeforeParameter = Current.BlockKind == BK_Block;
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000576 ++State.ParenLevel;
577 }
578
579 // If this '[' opens an ObjC call, determine whether all parameters fit into
580 // one line and put one per line if they don't.
581 if (Current.is(tok::l_square) && Current.Type == TT_ObjCMethodExpr &&
582 Current.MatchingParen != NULL) {
Daniel Jasper567dcf92013-09-05 09:29:45 +0000583 if (getLengthToMatchingParen(Current) + State.Column >
584 getColumnLimit(State))
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000585 State.Stack.back().BreakBeforeParameter = true;
586 }
587
588 // If we encounter a closing ), ], } or >, we can remove a level from our
589 // stacks.
Daniel Jasper7143a212013-08-28 09:17:37 +0000590 if (State.Stack.size() > 1 &&
591 (Current.isOneOf(tok::r_paren, tok::r_square) ||
Daniel Jasper567dcf92013-09-05 09:29:45 +0000592 (Current.is(tok::r_brace) && State.NextToken != State.Line->First) ||
Daniel Jasper7143a212013-08-28 09:17:37 +0000593 State.NextToken->Type == TT_TemplateCloser)) {
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000594 State.Stack.pop_back();
595 --State.ParenLevel;
596 }
597 if (Current.is(tok::r_square)) {
598 // If this ends the array subscript expr, reset the corresponding value.
599 const FormatToken *NextNonComment = Current.getNextNonComment();
600 if (NextNonComment && NextNonComment->isNot(tok::l_square))
601 State.Stack.back().StartOfArraySubscripts = 0;
602 }
603
604 // Remove scopes created by fake parenthesis.
Daniel Jasper567dcf92013-09-05 09:29:45 +0000605 if (Current.isNot(tok::r_brace) ||
606 (Current.MatchingParen && Current.MatchingParen->BlockKind != BK_Block)) {
Daniel Jasper1a925bc2013-09-05 10:48:50 +0000607 // Don't remove FakeRParens attached to r_braces that surround nested blocks
608 // as they will have been removed early (see above).
Daniel Jasper567dcf92013-09-05 09:29:45 +0000609 for (unsigned i = 0, e = Current.FakeRParens; i != e; ++i) {
610 unsigned VariablePos = State.Stack.back().VariablePos;
611 State.Stack.pop_back();
612 State.Stack.back().VariablePos = VariablePos;
613 }
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000614 }
615
616 if (Current.is(tok::string_literal) && State.StartOfStringLiteral == 0) {
617 State.StartOfStringLiteral = State.Column;
618 } else if (!Current.isOneOf(tok::comment, tok::identifier, tok::hash,
619 tok::string_literal)) {
620 State.StartOfStringLiteral = 0;
621 }
622
Alexander Kornienko83a7dcd2013-09-10 09:38:25 +0000623 State.Column += Current.ColumnWidth;
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000624 State.NextToken = State.NextToken->Next;
Daniel Jasperd489f8c2013-08-27 11:09:05 +0000625 unsigned Penalty = breakProtrudingToken(Current, State, DryRun);
Daniel Jasper567dcf92013-09-05 09:29:45 +0000626 if (State.Column > getColumnLimit(State)) {
627 unsigned ExcessCharacters = State.Column - getColumnLimit(State);
628 Penalty += Style.PenaltyExcessCharacter * ExcessCharacters;
629 }
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000630
Daniel Jasperd4a03db2013-08-22 15:00:41 +0000631 // If the previous has a special role, let it consume tokens as appropriate.
632 // It is necessary to start at the previous token for the only implemented
633 // role (comma separated list). That way, the decision whether or not to break
634 // after the "{" is already done and both options are tried and evaluated.
635 // FIXME: This is ugly, find a better way.
636 if (Previous && Previous->Role)
637 Penalty += Previous->Role->format(State, this, DryRun);
638
639 return Penalty;
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000640}
641
Alexander Kornienko6f6154c2013-09-10 12:29:48 +0000642unsigned ContinuationIndenter::addMultilineToken(const FormatToken &Current,
643 LineState &State) {
Alexander Kornienkodcc0c5b2013-08-29 17:32:57 +0000644 // Break before further function parameters on all levels.
645 for (unsigned i = 0, e = State.Stack.size(); i != e; ++i)
646 State.Stack[i].BreakBeforeParameter = true;
647
Alexander Kornienko83a7dcd2013-09-10 09:38:25 +0000648 unsigned ColumnsUsed = State.Column;
Alexander Kornienko4b762a92013-09-02 13:58:14 +0000649 // We can only affect layout of the first and the last line, so the penalty
650 // for all other lines is constant, and we ignore it.
Alexander Kornienko0b62cc32013-09-05 14:08:34 +0000651 State.Column = Current.LastLineColumnWidth;
Alexander Kornienko4b762a92013-09-02 13:58:14 +0000652
Daniel Jasper567dcf92013-09-05 09:29:45 +0000653 if (ColumnsUsed > getColumnLimit(State))
654 return Style.PenaltyExcessCharacter * (ColumnsUsed - getColumnLimit(State));
Alexander Kornienkodcc0c5b2013-08-29 17:32:57 +0000655 return 0;
656}
657
Alexander Kornienko2c2f7292013-09-16 20:20:49 +0000658static bool getRawStringLiteralPrefixPostfix(StringRef Text,
659 StringRef &Prefix,
660 StringRef &Postfix) {
661 if (Text.startswith(Prefix = "R\"") || Text.startswith(Prefix = "uR\"") ||
662 Text.startswith(Prefix = "UR\"") || Text.startswith(Prefix = "u8R\"") ||
663 Text.startswith(Prefix = "LR\"")) {
664 size_t ParenPos = Text.find('(');
665 if (ParenPos != StringRef::npos) {
666 StringRef Delimiter =
667 Text.substr(Prefix.size(), ParenPos - Prefix.size());
668 Prefix = Text.substr(0, ParenPos + 1);
669 Postfix = Text.substr(Text.size() - 2 - Delimiter.size());
670 return Postfix.front() == ')' && Postfix.back() == '"' &&
671 Postfix.substr(1).startswith(Delimiter);
672 }
673 }
674 return false;
675}
676
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000677unsigned ContinuationIndenter::breakProtrudingToken(const FormatToken &Current,
678 LineState &State,
679 bool DryRun) {
Alexander Kornienko6f6154c2013-09-10 12:29:48 +0000680 // Don't break multi-line tokens other than block comments. Instead, just
681 // update the state.
682 if (Current.Type != TT_BlockComment && Current.IsMultiline)
683 return addMultilineToken(Current, State);
684
Alexander Kornienko2c2f7292013-09-16 20:20:49 +0000685 if (!Current.isOneOf(tok::string_literal, tok::wide_string_literal,
686 tok::utf8_string_literal, tok::utf16_string_literal,
687 tok::utf32_string_literal, tok::comment))
Daniel Jaspered51c022013-08-23 10:05:49 +0000688 return 0;
689
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000690 llvm::OwningPtr<BreakableToken> Token;
Alexander Kornienko83a7dcd2013-09-10 09:38:25 +0000691 unsigned StartColumn = State.Column - Current.ColumnWidth;
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000692
Alexander Kornienko2c2f7292013-09-16 20:20:49 +0000693 if (Current.isOneOf(tok::string_literal, tok::wide_string_literal,
694 tok::utf8_string_literal, tok::utf16_string_literal,
695 tok::utf32_string_literal) &&
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000696 Current.Type != TT_ImplicitStringLiteral) {
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000697 // Exempts unterminated string literals from line breaking. The user will
698 // likely want to terminate the string before any line breaking is done.
699 if (Current.IsUnterminatedLiteral)
700 return 0;
701
Alexander Kornienko2c2f7292013-09-16 20:20:49 +0000702 StringRef Text = Current.TokenText;
703 StringRef Prefix;
704 StringRef Postfix;
705 // FIXME: Handle whitespace between '_T', '(', '"..."', and ')'.
706 // FIXME: Store Prefix and Suffix (or PrefixLength and SuffixLength to
707 // reduce the overhead) for each FormatToken, which is a string, so that we
708 // don't run multiple checks here on the hot path.
709 if ((Text.endswith(Postfix = "\"") &&
710 (Text.startswith(Prefix = "\"") || Text.startswith(Prefix = "u\"") ||
711 Text.startswith(Prefix = "U\"") || Text.startswith(Prefix = "u8\"") ||
712 Text.startswith(Prefix = "L\""))) ||
713 (Text.startswith(Prefix = "_T(\"") && Text.endswith(Postfix = "\")")) ||
714 getRawStringLiteralPrefixPostfix(Text, Prefix, Postfix)) {
Alexander Kornienko3d9ffcf2013-09-27 16:14:22 +0000715 Token.reset(new BreakableStringLiteral(
716 Current, State.Line->Level, StartColumn, Prefix, Postfix,
717 State.Line->InPPDirective, Encoding, Style));
Alexander Kornienko2c2f7292013-09-16 20:20:49 +0000718 } else {
719 return 0;
720 }
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000721 } else if (Current.Type == TT_BlockComment && Current.isTrailingComment()) {
722 Token.reset(new BreakableBlockComment(
Alexander Kornienko3d9ffcf2013-09-27 16:14:22 +0000723 Current, State.Line->Level, StartColumn, Current.OriginalColumn,
724 !Current.Previous, State.Line->InPPDirective, Encoding, Style));
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000725 } else if (Current.Type == TT_LineComment &&
726 (Current.Previous == NULL ||
727 Current.Previous->Type != TT_ImplicitStringLiteral)) {
Alexander Kornienko3d9ffcf2013-09-27 16:14:22 +0000728 Token.reset(new BreakableLineComment(Current, State.Line->Level,
729 StartColumn, State.Line->InPPDirective,
730 Encoding, Style));
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000731 } else {
732 return 0;
733 }
Daniel Jasper567dcf92013-09-05 09:29:45 +0000734 if (Current.UnbreakableTailLength >= getColumnLimit(State))
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000735 return 0;
736
Daniel Jasper567dcf92013-09-05 09:29:45 +0000737 unsigned RemainingSpace =
738 getColumnLimit(State) - Current.UnbreakableTailLength;
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000739 bool BreakInserted = false;
740 unsigned Penalty = 0;
741 unsigned RemainingTokenColumns = 0;
742 for (unsigned LineIndex = 0, EndIndex = Token->getLineCount();
743 LineIndex != EndIndex; ++LineIndex) {
744 if (!DryRun)
745 Token->replaceWhitespaceBefore(LineIndex, Whitespaces);
746 unsigned TailOffset = 0;
747 RemainingTokenColumns =
748 Token->getLineLengthAfterSplit(LineIndex, TailOffset, StringRef::npos);
749 while (RemainingTokenColumns > RemainingSpace) {
750 BreakableToken::Split Split =
Daniel Jasper567dcf92013-09-05 09:29:45 +0000751 Token->getSplit(LineIndex, TailOffset, getColumnLimit(State));
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000752 if (Split.first == StringRef::npos) {
753 // The last line's penalty is handled in addNextStateToQueue().
754 if (LineIndex < EndIndex - 1)
755 Penalty += Style.PenaltyExcessCharacter *
756 (RemainingTokenColumns - RemainingSpace);
757 break;
758 }
759 assert(Split.first != 0);
760 unsigned NewRemainingTokenColumns = Token->getLineLengthAfterSplit(
761 LineIndex, TailOffset + Split.first + Split.second, StringRef::npos);
762 assert(NewRemainingTokenColumns < RemainingTokenColumns);
763 if (!DryRun)
764 Token->insertBreak(LineIndex, TailOffset, Split, Whitespaces);
Daniel Jasperf5461782013-08-28 10:03:58 +0000765 Penalty += Current.SplitPenalty;
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000766 unsigned ColumnsUsed =
767 Token->getLineLengthAfterSplit(LineIndex, TailOffset, Split.first);
Daniel Jasper567dcf92013-09-05 09:29:45 +0000768 if (ColumnsUsed > getColumnLimit(State)) {
769 Penalty += Style.PenaltyExcessCharacter *
770 (ColumnsUsed - getColumnLimit(State));
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000771 }
772 TailOffset += Split.first + Split.second;
773 RemainingTokenColumns = NewRemainingTokenColumns;
774 BreakInserted = true;
775 }
776 }
777
778 State.Column = RemainingTokenColumns;
779
780 if (BreakInserted) {
781 // If we break the token inside a parameter list, we need to break before
782 // the next parameter on all levels, so that the next parameter is clearly
783 // visible. Line comments already introduce a break.
784 if (Current.Type != TT_LineComment) {
785 for (unsigned i = 0, e = State.Stack.size(); i != e; ++i)
786 State.Stack[i].BreakBeforeParameter = true;
787 }
788
Daniel Jasperf5461782013-08-28 10:03:58 +0000789 Penalty += Current.is(tok::string_literal) ? Style.PenaltyBreakString
790 : Style.PenaltyBreakComment;
791
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000792 State.Stack.back().LastSpace = StartColumn;
793 }
794 return Penalty;
795}
796
Daniel Jasper567dcf92013-09-05 09:29:45 +0000797unsigned ContinuationIndenter::getColumnLimit(const LineState &State) const {
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000798 // In preprocessor directives reserve two chars for trailing " \"
Daniel Jasper567dcf92013-09-05 09:29:45 +0000799 return Style.ColumnLimit - (State.Line->InPPDirective ? 2 : 0);
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000800}
801
Daniel Jasper4df1ff92013-08-23 11:57:34 +0000802bool ContinuationIndenter::NextIsMultilineString(const LineState &State) {
803 const FormatToken &Current = *State.NextToken;
804 if (!Current.is(tok::string_literal))
805 return false;
Alexander Kornienkodcc0c5b2013-08-29 17:32:57 +0000806 // We never consider raw string literals "multiline" for the purpose of
807 // AlwaysBreakBeforeMultilineStrings implementation.
808 if (Current.TokenText.startswith("R\""))
809 return false;
Alexander Kornienko83a7dcd2013-09-10 09:38:25 +0000810 if (Current.IsMultiline)
Alexander Kornienkodcc0c5b2013-08-29 17:32:57 +0000811 return true;
Daniel Jasper4df1ff92013-08-23 11:57:34 +0000812 if (Current.getNextNonComment() &&
813 Current.getNextNonComment()->is(tok::string_literal))
814 return true; // Implicit concatenation.
Alexander Kornienko83a7dcd2013-09-10 09:38:25 +0000815 if (State.Column + Current.ColumnWidth + Current.UnbreakableTailLength >
Daniel Jasper4df1ff92013-08-23 11:57:34 +0000816 Style.ColumnLimit)
817 return true; // String will be split.
Alexander Kornienkodcc0c5b2013-08-29 17:32:57 +0000818 return false;
Daniel Jasper4df1ff92013-08-23 11:57:34 +0000819}
820
Daniel Jasper6b2afe42013-08-16 11:20:30 +0000821} // namespace format
822} // namespace clang