From 3948516a03ba3405e2578d27fcaf898e58dc88b5 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Thu, 22 May 2014 09:00:33 +0000 Subject: clang-format: Correctly identify multiplications in braces init lists. Before: int i{a *b}; After: int i{a * b}; Also fix unrelated issue where braced init lists were counted as blocks and prevented single-line functions. llvm-svn: 209412 --- clang/lib/Format/Format.cpp | 2 +- clang/lib/Format/TokenAnnotator.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'clang/lib/Format') diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 03177e586ad..471af1d5393 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -690,7 +690,7 @@ private: if (I[1]->Last->Type == TT_LineComment) return 0; do { - if (Tok->isOneOf(tok::l_brace, tok::r_brace) && + if (Tok->is(tok::l_brace) && Tok->BlockKind != BK_BracedInit && !Style.AllowShortBlocksOnASingleLine) return 0; Tok = Tok->Next; diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index dca20d2d75d..f3d655ace5b 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -298,6 +298,8 @@ private: ScopedContextCreator ContextCreator(*this, tok::l_brace, 1); Contexts.back().ColonIsDictLiteral = true; + if (Left->BlockKind == BK_BracedInit) + Contexts.back().IsExpression = true; while (CurrentToken) { if (CurrentToken->is(tok::r_brace)) { -- cgit v1.2.3