Update clang-format

This commit is contained in:
Jonathan Müller 2018-09-20 19:57:03 +02:00
commit 9f18b7f4d8
89 changed files with 11377 additions and 11546 deletions

View file

@ -46,81 +46,84 @@ alignas(type) int var;
auto file = parse({}, "cpp_attribute.cpp", code);
auto check_attribute = [](const cpp_attribute& attr, const char* name,
type_safe::optional<std::string> scope, bool variadic,
const char* args, cpp_attribute_kind kind) {
REQUIRE(attr.kind() == kind);
REQUIRE(attr.name() == name);
REQUIRE(attr.scope() == scope);
REQUIRE(attr.is_variadic() == variadic);
auto check_attribute
= [](const cpp_attribute& attr, const char* name, type_safe::optional<std::string> scope,
bool variadic, const char* args, cpp_attribute_kind kind) {
REQUIRE(attr.kind() == kind);
REQUIRE(attr.name() == name);
REQUIRE(attr.scope() == scope);
REQUIRE(attr.is_variadic() == variadic);
if (attr.arguments())
REQUIRE(attr.arguments().value().as_string() == args);
else
REQUIRE(*args == '\0');
};
if (attr.arguments())
REQUIRE(attr.arguments().value().as_string() == args);
else
REQUIRE(*args == '\0');
};
auto count =
test_visit<cpp_function>(*file,
[&](const cpp_entity& e) {
auto& attributes = e.attributes();
REQUIRE(attributes.size() >= 1u);
auto& attr = attributes.front();
auto count
= test_visit<cpp_function>(*file,
[&](const cpp_entity& e) {
auto& attributes = e.attributes();
REQUIRE(attributes.size() >= 1u);
auto& attr = attributes.front();
if (e.name() == "a" || e.name() == "b")
{
REQUIRE(attributes.size() == 2u);
REQUIRE(has_attribute(e, "attribute1"));
REQUIRE(has_attribute(e, "attribute2"));
check_attribute(attr, "attribute1", type_safe::nullopt,
false, "", cpp_attribute_kind::unknown);
check_attribute(attributes[1u], "attribute2",
type_safe::nullopt, false, "",
cpp_attribute_kind::unknown);
}
else if (e.name() == "c")
check_attribute(attr, "variadic", type_safe::nullopt, true,
"", cpp_attribute_kind::unknown);
else if (e.name() == "d")
{
REQUIRE(has_attribute(e, "ns::attribute"));
check_attribute(attr, "attribute", "ns", false, "",
cpp_attribute_kind::unknown);
}
else if (e.name() == "e")
check_attribute(attr, "attribute", type_safe::nullopt,
false, R"(arg1,arg2,+(){},42,"Hello!")",
cpp_attribute_kind::unknown);
else if (e.name() == "f")
{
REQUIRE(attributes.size() == 2u);
check_attribute(attr, "attribute", "ns", false, "+,-,0 4",
cpp_attribute_kind::unknown);
check_attribute(attributes[1u], "other_attribute",
type_safe::nullopt, false, "",
cpp_attribute_kind::unknown);
}
else if (e.name() == "g")
{
REQUIRE(has_attribute(e, cpp_attribute_kind::deprecated));
check_attribute(attr, "deprecated", type_safe::nullopt,
false, "", cpp_attribute_kind::deprecated);
}
else if (e.name() == "h")
check_attribute(attr, "maybe_unused", type_safe::nullopt,
false, "",
cpp_attribute_kind::maybe_unused);
else if (e.name() == "i")
check_attribute(attr, "nodiscard", type_safe::nullopt,
false, "", cpp_attribute_kind::nodiscard);
else if (e.name() == "j")
check_attribute(attr, "noreturn", type_safe::nullopt,
false, "", cpp_attribute_kind::noreturn);
else if (e.name() == "k")
check_attribute(attr, "const", type_safe::nullopt, false,
"", cpp_attribute_kind::unknown);
},
false);
if (e.name() == "a" || e.name() == "b")
{
REQUIRE(attributes.size() == 2u);
REQUIRE(has_attribute(e, "attribute1"));
REQUIRE(has_attribute(e, "attribute2"));
check_attribute(attr, "attribute1", type_safe::nullopt,
false, "", cpp_attribute_kind::unknown);
check_attribute(attributes[1u], "attribute2",
type_safe::nullopt, false, "",
cpp_attribute_kind::unknown);
}
else if (e.name() == "c")
check_attribute(attr, "variadic", type_safe::nullopt,
true, "", cpp_attribute_kind::unknown);
else if (e.name() == "d")
{
REQUIRE(has_attribute(e, "ns::attribute"));
check_attribute(attr, "attribute", "ns", false, "",
cpp_attribute_kind::unknown);
}
else if (e.name() == "e")
check_attribute(attr, "attribute", type_safe::nullopt,
false, R"(arg1,arg2,+(){},42,"Hello!")",
cpp_attribute_kind::unknown);
else if (e.name() == "f")
{
REQUIRE(attributes.size() == 2u);
check_attribute(attr, "attribute", "ns", false,
"+,-,0 4", cpp_attribute_kind::unknown);
check_attribute(attributes[1u], "other_attribute",
type_safe::nullopt, false, "",
cpp_attribute_kind::unknown);
}
else if (e.name() == "g")
{
REQUIRE(
has_attribute(e, cpp_attribute_kind::deprecated));
check_attribute(attr, "deprecated", type_safe::nullopt,
false, "",
cpp_attribute_kind::deprecated);
}
else if (e.name() == "h")
check_attribute(attr, "maybe_unused", type_safe::nullopt,
false, "",
cpp_attribute_kind::maybe_unused);
else if (e.name() == "i")
check_attribute(attr, "nodiscard", type_safe::nullopt,
false, "",
cpp_attribute_kind::nodiscard);
else if (e.name() == "j")
check_attribute(attr, "noreturn", type_safe::nullopt,
false, "", cpp_attribute_kind::noreturn);
else if (e.name() == "k")
check_attribute(attr, "const", type_safe::nullopt, false,
"", cpp_attribute_kind::unknown);
},
false);
REQUIRE(count == 10);
count = test_visit<cpp_class>(*file,