clang-format: Make IncludeCategories configurable in .clang-format file.
This was made much easier by introducing an IncludeCategory struct to
replace the previously used std::pair.
Also, cleaned up documentation and added examples.
llvm-svn: 249392
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 0921b38..a34aa88 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -9646,6 +9646,8 @@
CHECK_PARSE("NamespaceIndentation: All", NamespaceIndentation,
FormatStyle::NI_All);
+ // FIXME: This is required because parsing a configuration simply overwrites
+ // the first N elements of the list instead of resetting it.
Style.ForEachMacros.clear();
std::vector<std::string> BoostForeach;
BoostForeach.push_back("BOOST_FOREACH");
@@ -9655,6 +9657,16 @@
BoostAndQForeach.push_back("Q_FOREACH");
CHECK_PARSE("ForEachMacros: [BOOST_FOREACH, Q_FOREACH]", ForEachMacros,
BoostAndQForeach);
+
+ Style.IncludeCategories.clear();
+ std::vector<FormatStyle::IncludeCategory> ExpectedCategories = {{"abc/.*", 2},
+ {".*", 1}};
+ CHECK_PARSE("IncludeCategories:\n"
+ " - Regex: abc/.*\n"
+ " Priority: 2\n"
+ " - Regex: .*\n"
+ " Priority: 1",
+ IncludeCategories, ExpectedCategories);
}
TEST_F(FormatTest, ParsesConfigurationWithLanguages) {