[PATCH] D94955: [clang-format] Treat ForEachMacros as loops

Marek Kurdej via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 14 07:04:19 PST 2022


curdeius marked 5 inline comments as done.
curdeius added inline comments.


================
Comment at: clang/unittests/Format/FormatTest.cpp:2181-2185
+  EXPECT_EQ(Style.AllowShortBlocksOnASingleLine, FormatStyle::SBS_Never);
+  EXPECT_EQ(Style.AllowShortLoopsOnASingleLine, false);
   verifyFormat("void f() {\n"
-               "  foreach (Item *item, itemlist) {}\n"
-               "  Q_FOREACH (Item *item, itemlist) {}\n"
-               "  BOOST_FOREACH (Item *item, itemlist) {}\n"
+               "  for (;;) {\n"
+               "  }\n"
----------------
The existing tests have changed here. I added the tests case for a pure `for` loop to show the similarity.
I also check values of AllowShortBlocksOnASingleLine/AllowShortLoopsOnASingleLine.


================
Comment at: clang/unittests/Format/FormatTest.cpp:2226
+
+  FormatStyle ShortBlocks = getLLVMStyle();
+  ShortBlocks.ForEachMacros.push_back("rng");
----------------
Euuh, I might need to so come clean up here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94955/new/

https://reviews.llvm.org/D94955



More information about the cfe-commits mailing list