Column = FormatTok->LastLineColumnWidth;
}
- if (std::find(ForEachMacros.begin(), ForEachMacros.end(),
+ if (!(Tokens.size() > 0 && Tokens.back()->Tok.getIdentifierInfo() &&
+ Tokens.back()->Tok.getIdentifierInfo()->getPPKeywordID() ==
+ tok::pp_define) &&
+ std::find(ForEachMacros.begin(), ForEachMacros.end(),
FormatTok->Tok.getIdentifierInfo()) != ForEachMacros.end())
FormatTok->Type = TT_ForEachMacro;
" BOOST_FOREACH (Item *item, itemlist) {}\n"
" UNKNOWN_FORACH(Item * item, itemlist) {}\n"
"}");
+
+ // As function-like macros.
+ verifyFormat("#define foreach(x, y)\n"
+ "#define Q_FOREACH(x, y)\n"
+ "#define BOOST_FOREACH(x, y)\n"
+ "#define UNKNOWN_FOREACH(x, y)\n");
+
+ // Not as function-like macros.
+ verifyFormat("#define foreach (x, y)\n"
+ "#define Q_FOREACH (x, y)\n"
+ "#define BOOST_FOREACH (x, y)\n"
+ "#define UNKNOWN_FOREACH (x, y)\n");
}
TEST_F(FormatTest, FormatsWhileLoop) {