Index: clang/lib/Format/UnwrappedLineParser.cpp =================================================================== --- clang/lib/Format/UnwrappedLineParser.cpp +++ clang/lib/Format/UnwrappedLineParser.cpp @@ -837,6 +837,10 @@ unsigned InitialLevel = Line->Level; nextToken(/*LevelDifference=*/AddLevels); + // Bail out if there are too many levels. Otherwise, the stack might overflow. + if (Line->Level > 300) + return IfStmtKind::NotIf; + if (MacroBlock && FormatTok->is(tok::l_paren)) parseParens();