Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions clang/lib/Format/TokenAnnotator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3901,6 +3901,11 @@ bool TokenAnnotator::mustBreakForReturnType(const AnnotatedLine &Line) const {
}

void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
if (Line.Computed)
return;

Line.Computed = true;

for (AnnotatedLine *ChildLine : Line.Children)
calculateFormattingInformation(*ChildLine);

Expand Down
3 changes: 3 additions & 0 deletions clang/lib/Format/TokenAnnotator.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ class AnnotatedLine {
/// \c True if this line contains a macro call for which an expansion exists.
bool ContainsMacroCall = false;

/// \c True if calculateFormattingInformation() has been called on this line.
bool Computed = false;

/// \c True if this line should be formatted, i.e. intersects directly or
/// indirectly with one of the input ranges.
bool Affected;
Expand Down
7 changes: 7 additions & 0 deletions clang/unittests/Format/FormatTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27386,6 +27386,13 @@ TEST_F(FormatTest, RemoveSemicolon) {
Style);
#endif

verifyFormat("auto sgf = [] {\n"
" ogl = {\n"
" a, b, c, d, e,\n"
" };\n"
"};",
Style);

Style.TypenameMacros.push_back("STRUCT");
verifyFormat("STRUCT(T, B) { int i; };", Style);
}
Expand Down
Loading