From fbc057ea73cf5c7b6ff77bf040c698a6021e23f9 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Fri, 18 Oct 2013 17:20:57 +0000 Subject: clang-format: Be more aggressive on incorrect code. Before, clang-format would not adjust leading indents if it found a structural error (e.g. unmatched {}). It seems, however, that clang-format has gotten good enough at parsing the code structure that this hurts in almost all cases. Commonly, while writing code, it is very useful to be able to correclty indent incomplete if statements or for loops. In case this leads to errors that we don't anticipate, we need to find out and fix those. This fixed llvm.org/PR17594. llvm-svn: 192988 --- clang/lib/Format/Format.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'clang/lib/Format') diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 3496712e3cf..90c3e9e96d5 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -915,10 +915,7 @@ public: } else if (TheLine.Type != LT_Invalid && (WasMoved || FormatPPDirective || touchesLine(TheLine))) { unsigned LevelIndent = getIndent(IndentForLevel, TheLine.Level); - if (FirstTok->WhitespaceRange.isValid() && - // Insert a break even if there is a structural error in case where - // we break apart a line consisting of multiple unwrapped lines. - (FirstTok->NewlinesBefore == 0 || !StructuralError)) { + if (FirstTok->WhitespaceRange.isValid()) { formatFirstToken(*TheLine.First, PreviousLine, TheLine.Level, Indent, TheLine.InPPDirective); } else { -- cgit v1.2.3