diff options
| author | Daniel Jasper <djasper@google.com> | 2013-06-06 09:11:58 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2013-06-06 09:11:58 +0000 |
| commit | 6dcecb6b33ee04a93ef4f94e8597f9b8679d1c5d (patch) | |
| tree | e257928d50f00da2b930bca4fa44b30a95295279 /clang/lib/Format | |
| parent | c87e0090592667a0e37f9f1caafd15453db4c597 (diff) | |
| download | bcm5719-llvm-6dcecb6b33ee04a93ef4f94e8597f9b8679d1c5d.tar.gz bcm5719-llvm-6dcecb6b33ee04a93ef4f94e8597f9b8679d1c5d.zip | |
Fix clang-format's expression parser for leading }s.
The leading "}" in the construct "} else if (..) {" was confusing the
expression parser. Thus, no fake parentheses were generated and the
indentation was broken in some cases.
llvm-svn: 183393
Diffstat (limited to 'clang/lib/Format')
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index fc53681394e..71a1a28c85f 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -773,7 +773,11 @@ private: /// operator precedence. class ExpressionParser { public: - ExpressionParser(AnnotatedLine &Line) : Current(Line.First) {} + ExpressionParser(AnnotatedLine &Line) : Current(Line.First) { + // Skip leading "}", e.g. in "} else if (...) {". + if (Current->is(tok::r_brace)) + next(); + } /// \brief Parse expressions with the given operatore precedence. void parse(int Precedence = 0) { |

