diff options
| author | Daniel Jasper <djasper@google.com> | 2014-04-01 12:55:11 +0000 | 
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2014-04-01 12:55:11 +0000 | 
| commit | e1e4319ab796b457ecd98ae27793d57ce1236f8f (patch) | |
| tree | 0e3b9a353584a13ff17153ef0c069156c23f645b /clang/unittests/Format | |
| parent | 1087f2980dd96ca4db2df1416020957cf0e3bfbc (diff) | |
| download | bcm5719-llvm-e1e4319ab796b457ecd98ae27793d57ce1236f8f.tar.gz bcm5719-llvm-e1e4319ab796b457ecd98ae27793d57ce1236f8f.zip  | |
clang-format: Support configurable list of foreach-macros.
This fixes llvm.org/PR17242.
Patch by Brian Green, thank you!
llvm-svn: 205307
Diffstat (limited to 'clang/unittests/Format')
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 16 | 
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 7332fd04e06..8c066e04288 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -465,6 +465,15 @@ TEST_F(FormatTest, RangeBasedForLoops) {                 "     aaaaaaaaaaaa.aaaaaaaaaaaa().aaaaaaaaa().a()) {\n}");  } +TEST_F(FormatTest, ForEachLoops) { +  verifyFormat("void f() {\n" +               "  foreach (Item *item, itemlist) {}\n" +               "  Q_FOREACH (Item *item, itemlist) {}\n" +               "  BOOST_FOREACH (Item *item, itemlist) {}\n" +               "  UNKNOWN_FORACH(Item * item, itemlist) {}\n" +               "}"); +} +  TEST_F(FormatTest, FormatsWhileLoop) {    verifyFormat("while (true) {\n}");    verifyFormat("while (true)\n" @@ -7607,6 +7616,13 @@ TEST_F(FormatTest, ParsesConfiguration) {                FormatStyle::NI_Inner);    CHECK_PARSE("NamespaceIndentation: All", NamespaceIndentation,                FormatStyle::NI_All); + +  Style.ForEachMacros.clear(); +  std::vector<std::string> BoostForeach = { "BOOST_FOREACH" }; +  CHECK_PARSE("ForEachMacros: [BOOST_FOREACH]", ForEachMacros, BoostForeach); +  std::vector<std::string> BoostAndQForeach = { "BOOST_FOREACH", "Q_FOREACH" }; +  CHECK_PARSE("ForEachMacros: [BOOST_FOREACH, Q_FOREACH]", ForEachMacros, +              BoostAndQForeach);  }  TEST_F(FormatTest, ParsesConfigurationWithLanguages) {  | 

