/// operator precedence.
class ExpressionParser {
public:
- ExpressionParser(AnnotatedLine &Line) : Current(Line.First) {
- // Skip leading "}", e.g. in "} else if (...) {".
- if (Current->is(tok::r_brace))
- next();
- }
+ ExpressionParser(AnnotatedLine &Line) : Current(Line.First) {}
/// \brief Parse expressions with the given operatore precedence.
void parse(int Precedence = 0) {
// At the end of the line or when an operator with higher precedence is
// found, insert fake parenthesis and return.
- if (!Current || Current->closesScope() ||
+ if (!Current || (Current->closesScope() && Current->MatchingParen) ||
(CurrentPrecedence != -1 && CurrentPrecedence < Precedence)) {
if (LatestOperator) {
LatestOperator->LastOperator = true;
" {kOsWin, \"Windows\"},\n"
" {kOsLinux, \"Linux\"},\n"
" {kOsCrOS, \"Chrome OS\"}};");
+ verifyFormat(
+ "struct {\n"
+ " unsigned bit;\n"
+ " const char *const name;\n"
+ "} kBitsToOs[] = {\n"
+ " {kOsMac, \"Mac\"},\n"
+ " {kOsWin, \"Windows\"},\n"
+ " {kOsLinux, \"Linux\"},\n"
+ " {kOsCrOS, \"Chrome OS\"},\n"
+ "};");
}
TEST_F(FormatTest, FormatsSmallMacroDefinitionsInSingleLine) {